[PHP-DEV] Bug #1014: php3_fdf_get_value in fdf.c does not work - error: Buffer too short From: kate <email protected>
Date: 12/30/98

From: kate <email protected>
Operating system: IRIX 6.3
PHP version: 3.0.6
PHP Bug Type: Misbehaving function
Bug description: php3_fdf_get_value in fdf.c does not work - error: Buffer too short

It seems that while the function FDFGetValue returns the size of the required buffer, an extra byte must be added for the null terminator. The following script does not have that error:

void php3_fdf_get_value(INTERNAL_FUNCTION_PARAMETERS) {
        pval *arg1, *arg2;
        int id, type;
        ASInt32 nr;
        char *buffer;
        FDFDoc fdf;
        FDFErc err;
        FDF_TLS_VARS;

        if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
                WRONG_PARAM_COUNT;
        }

        convert_to_long(arg1);
        convert_to_string(arg2);
        id=arg1->value.lval;
        fdf = php3_list_find(id,&type);
        if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
                php3_error(E_WARNING,"Unable to find file identifier %d",id);
                RETURN_FALSE;
        }

        err = FDFGetValue(fdf, arg2->value.str.val, NULL, 0, &nr);
        if(err != FDFErcOK)
                printf("Aiii, error\n");
        /********************************************************************
        I have inserted the following line:
        *********************************************************************/
        nr++;
        buffer = (char *)emalloc(nr);
        err = FDFGetValue(fdf, arg2->value.str.val, buffer, nr, &nr);
        
        if(err != FDFErcOK)
                printf("Aiii, error: %d\n", err);
        RETURN_STRING(buffer, 0);
}

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>