Bug #1014: php3_fdf_get_value in fdf.c does not work - error: Buffer too short

From: Date: Wed, 30 Dec 1998 07:07:51 +0000
Subject: Bug #1014: php3_fdf_get_value in fdf.c does not work - error: Buffer too short
Groups: php.dev 
Request: Send a blank email to php-dev+get-3162@lists.php.net to get a copy of this message
From: kate@vis.co.za 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@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3162) next »