bug ???
| From: | D. Walsh | Date: | Mon, 12 Dec 2005 21:34:08 +0000 |
| Subject: | bug ??? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-21201@lists.php.net to get a copy of this message | ||
I have the following code, it works properly under 4.3.9, 4.3.10. 4.3.11, 4.4.0, 5.0.2, 5.0.3, 5.0.4
Under 5.1.2-dev, it doesn't perform as expected.
I've scripted the configure options so all builds are the same so the only thing changing is the version of PHP.
Here's a link which shows what the results should be and what they are.
http://www.daleenterprise.com/test.php
I'm not sure if a bug report is really required as it may be some minor change I am unaware of and the included dev docs don't state so how to proceed?
Here's the code for the two routines in question..
/* {{{ proto string clam_scan_buffer(string $buffer)
Scan a given buffer for viruses. Returns false if no virus present */
PHP_FUNCTION(clam_scan_buffer) {
zval **buffer;
char *real_buffer = NULL;
long retb;
const char *virname;
/* make sure virus dbdir exists - prevents a segfault */
if (cl_error) {
php_error( E_WARNING, "Virus database directory (%s) does not exist", INI_STR("clam.virus_dbdir")) ;
RETURN_FALSE;
}
/* parse zend input */
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &buffer) == FAILURE)) {
WRONG_PARAM_COUNT;
}
/* convert zval input to real strings */
real_buffer = Z_STRVAL_PP(buffer);
/* scan buffer */
retb = cl_scanbuff(real_buffer ,strlen(real_buffer), &virname, root);
if (retb == CL_VIRUS) {
RETURN_STRINGL((char *)virname,strlen(virname),1);
} else if (retb == CL_CLEAN) {
RETURN_FALSE;
} else {
php_error(E_WARNING,"error: %s", cl_strerror(retb));
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto string clam_scan_file(string $file)
Scan a given file for viruses. Returns false if no virus present */
PHP_FUNCTION(clam_scan_file) {
zval **file;
char *real_file = NULL;
long options = CL_SCAN_STDOPT;
long retf;
const char *virname;
/* make sure virus dbdir exists - prevents a segfault */
if (cl_error) {
php_error( E_WARNING, "Virus database directory (%s) does not exist", INI_STR("clam.virus_dbdir")) ;
RETURN_FALSE;
}
/* parse zend input */
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
WRONG_PARAM_COUNT;
}
/* convert zval input to real strings */
real_file = Z_STRVAL_PP(file);
/* scan file */
/*RETURN_STRINGL(real_file,strlen(real_file),1);*/
retf = cl_scanfile(real_file, &virname, NULL, root, &limits, options);
/* return result */
if (retf == CL_VIRUS) {
RETURN_STRINGL((char *)virname,strlen(virname),1);
} else if (retf == CL_CLEAN) {
RETURN_FALSE;
} else {
php_error(E_WARNING,"error: %s", cl_strerror(retf));
RETURN_FALSE;
}
}
/* }}} */