idx int64 | func_before string | Vulnerability Classification string | vul int64 | func_after string | patch string | CWE ID string | lines_before string | lines_after string |
|---|---|---|---|---|---|---|---|---|
8,900 | PHP_METHOD(Phar, setSignatureAlgorithm)
{
zend_long algo;
char *error, *key = NULL;
size_t key_len = 0;
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot set signature algorithm, phar is read-only");
return;
}
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "l|s", &algo, &key, &key_len) != SUCCESS) {
return;
}
switch (algo) {
case PHAR_SIG_SHA256:
case PHAR_SIG_SHA512:
#ifndef PHAR_HASH_OK
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled and built non-shared");
return;
#endif
case PHAR_SIG_MD5:
case PHAR_SIG_SHA1:
case PHAR_SIG_OPENSSL:
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
phar_obj->archive->sig_flags = algo;
phar_obj->archive->is_modified = 1;
PHAR_G(openssl_privatekey) = key;
PHAR_G(openssl_privatekey_len) = key_len;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
break;
default:
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Unknown signature algorithm specified");
}
}
| Exec Code | 0 | PHP_METHOD(Phar, setSignatureAlgorithm)
{
zend_long algo;
char *error, *key = NULL;
size_t key_len = 0;
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot set signature algorithm, phar is read-only");
return;
}
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "l|s", &algo, &key, &key_len) != SUCCESS) {
return;
}
switch (algo) {
case PHAR_SIG_SHA256:
case PHAR_SIG_SHA512:
#ifndef PHAR_HASH_OK
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled and built non-shared");
return;
#endif
case PHAR_SIG_MD5:
case PHAR_SIG_SHA1:
case PHAR_SIG_OPENSSL:
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
phar_obj->archive->sig_flags = algo;
phar_obj->archive->is_modified = 1;
PHAR_G(openssl_privatekey) = key;
PHAR_G(openssl_privatekey_len) = key_len;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
break;
default:
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Unknown signature algorithm specified");
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,901 | PHP_METHOD(Phar, getModified)
{
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(phar_obj->archive->is_modified);
}
| Exec Code | 0 | PHP_METHOD(Phar, getModified)
{
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(phar_obj->archive->is_modified);
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,902 | PHP_METHOD(Phar, compress)
{
zend_long method;
char *ext = NULL;
size_t ext_len = 0;
php_uint32 flags;
zend_object *ret;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s", &method, &ext, &ext_len) == FAILURE) {
return;
}
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot compress phar archive, phar is read-only");
return;
}
if (phar_obj->archive->is_zip) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot compress zip-based archives with whole-archive compression");
return;
}
switch (method) {
case 0:
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
}
flags = PHAR_FILE_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
}
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
if (phar_obj->archive->is_tar) {
ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_TAR, ext, flags);
} else {
ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_PHAR, ext, flags);
}
if (ret) {
ZVAL_OBJ(return_value, ret);
} else {
RETURN_NULL();
}
}
| Exec Code | 0 | PHP_METHOD(Phar, compress)
{
zend_long method;
char *ext = NULL;
size_t ext_len = 0;
php_uint32 flags;
zend_object *ret;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s", &method, &ext, &ext_len) == FAILURE) {
return;
}
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot compress phar archive, phar is read-only");
return;
}
if (phar_obj->archive->is_zip) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot compress zip-based archives with whole-archive compression");
return;
}
switch (method) {
case 0:
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
}
flags = PHAR_FILE_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
}
flags = PHAR_FILE_COMPRESSED_BZ2;
break;
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
if (phar_obj->archive->is_tar) {
ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_TAR, ext, flags);
} else {
ret = phar_convert_to_other(phar_obj->archive, PHAR_FORMAT_PHAR, ext, flags);
}
if (ret) {
ZVAL_OBJ(return_value, ret);
} else {
RETURN_NULL();
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,903 | PHP_METHOD(Phar, compressFiles)
{
char *error;
php_uint32 flags;
zend_long method;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
return;
}
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress files within archive with gzip, enable ext/zlib in php.ini");
return;
}
flags = PHAR_ENT_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress files within archive with bz2, enable ext/bz2 in php.ini");
return;
}
flags = PHAR_ENT_COMPRESSED_BZ2;
break;
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
if (phar_obj->archive->is_tar) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with Gzip compression, tar archives cannot compress individual files, use compress() to compress the whole archive");
return;
}
if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
if (flags == PHAR_FILE_COMPRESSED_GZ) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Gzip, some are compressed as bzip2 and cannot be decompressed");
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Bzip2, some are compressed as gzip and cannot be decompressed");
}
return;
}
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
pharobj_set_compression(&phar_obj->archive->manifest, flags);
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
}
}
| Exec Code | 0 | PHP_METHOD(Phar, compressFiles)
{
char *error;
php_uint32 flags;
zend_long method;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
return;
}
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress files within archive with gzip, enable ext/zlib in php.ini");
return;
}
flags = PHAR_ENT_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress files within archive with bz2, enable ext/bz2 in php.ini");
return;
}
flags = PHAR_ENT_COMPRESSED_BZ2;
break;
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2");
return;
}
if (phar_obj->archive->is_tar) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with Gzip compression, tar archives cannot compress individual files, use compress() to compress the whole archive");
return;
}
if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
if (flags == PHAR_FILE_COMPRESSED_GZ) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Gzip, some are compressed as bzip2 and cannot be decompressed");
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress all files as Bzip2, some are compressed as gzip and cannot be decompressed");
}
return;
}
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
pharobj_set_compression(&phar_obj->archive->manifest, flags);
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,904 | PHP_METHOD(Phar, decompressFiles)
{
char *error;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot decompress all files, some are compressed as bzip2 or gzip and cannot be decompressed");
return;
}
if (phar_obj->archive->is_tar) {
RETURN_TRUE;
} else {
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
pharobj_set_compression(&phar_obj->archive->manifest, PHAR_ENT_COMPRESSED_NONE);
}
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
}
RETURN_TRUE;
}
| Exec Code | 0 | PHP_METHOD(Phar, decompressFiles)
{
char *error;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
if (!pharobj_cancompress(&phar_obj->archive->manifest)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot decompress all files, some are compressed as bzip2 or gzip and cannot be decompressed");
return;
}
if (phar_obj->archive->is_tar) {
RETURN_TRUE;
} else {
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
pharobj_set_compression(&phar_obj->archive->manifest, PHAR_ENT_COMPRESSED_NONE);
}
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
}
RETURN_TRUE;
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,905 | PHP_METHOD(Phar, getStub)
{
size_t len;
zend_string *buf;
php_stream *fp;
php_stream_filter *filter = NULL;
phar_entry_info *stub;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (phar_obj->archive->is_tar || phar_obj->archive->is_zip) {
if (NULL != (stub = zend_hash_str_find_ptr(&(phar_obj->archive->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
if (phar_obj->archive->fp && !phar_obj->archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) {
fp = phar_obj->archive->fp;
} else {
if (!(fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", 0, NULL))) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to open phar \"%s\"", phar_obj->archive->fname);
return;
}
if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
char *filter_name;
if ((filter_name = phar_decompress_filter(stub, 0)) != NULL) {
filter = php_stream_filter_create(filter_name, NULL, php_stream_is_persistent(fp));
} else {
filter = NULL;
}
if (!filter) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->archive->fname, phar_decompress_filter(stub, 1));
return;
}
php_stream_filter_append(&fp->readfilters, filter);
}
}
if (!fp) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
return;
}
php_stream_seek(fp, stub->offset_abs, SEEK_SET);
len = stub->uncompressed_filesize;
goto carry_on;
} else {
RETURN_EMPTY_STRING();
}
}
len = phar_obj->archive->halt_offset;
if (phar_obj->archive->fp && !phar_obj->archive->is_brandnew) {
fp = phar_obj->archive->fp;
} else {
fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", 0, NULL);
}
if (!fp) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
return;
}
php_stream_rewind(fp);
carry_on:
buf = zend_string_alloc(len, 0);
if (len != php_stream_read(fp, ZSTR_VAL(buf), len)) {
if (fp != phar_obj->archive->fp) {
php_stream_close(fp);
}
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
zend_string_release(buf);
return;
}
if (filter) {
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1);
}
if (fp != phar_obj->archive->fp) {
php_stream_close(fp);
}
ZSTR_VAL(buf)[len] = '\0';
ZSTR_LEN(buf) = len;
RETVAL_STR(buf);
}
| Exec Code | 0 | PHP_METHOD(Phar, getStub)
{
size_t len;
zend_string *buf;
php_stream *fp;
php_stream_filter *filter = NULL;
phar_entry_info *stub;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (phar_obj->archive->is_tar || phar_obj->archive->is_zip) {
if (NULL != (stub = zend_hash_str_find_ptr(&(phar_obj->archive->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) {
if (phar_obj->archive->fp && !phar_obj->archive->is_brandnew && !(stub->flags & PHAR_ENT_COMPRESSION_MASK)) {
fp = phar_obj->archive->fp;
} else {
if (!(fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", 0, NULL))) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to open phar \"%s\"", phar_obj->archive->fname);
return;
}
if (stub->flags & PHAR_ENT_COMPRESSION_MASK) {
char *filter_name;
if ((filter_name = phar_decompress_filter(stub, 0)) != NULL) {
filter = php_stream_filter_create(filter_name, NULL, php_stream_is_persistent(fp));
} else {
filter = NULL;
}
if (!filter) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->archive->fname, phar_decompress_filter(stub, 1));
return;
}
php_stream_filter_append(&fp->readfilters, filter);
}
}
if (!fp) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
return;
}
php_stream_seek(fp, stub->offset_abs, SEEK_SET);
len = stub->uncompressed_filesize;
goto carry_on;
} else {
RETURN_EMPTY_STRING();
}
}
len = phar_obj->archive->halt_offset;
if (phar_obj->archive->fp && !phar_obj->archive->is_brandnew) {
fp = phar_obj->archive->fp;
} else {
fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", 0, NULL);
}
if (!fp) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
return;
}
php_stream_rewind(fp);
carry_on:
buf = zend_string_alloc(len, 0);
if (len != php_stream_read(fp, ZSTR_VAL(buf), len)) {
if (fp != phar_obj->archive->fp) {
php_stream_close(fp);
}
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to read stub");
zend_string_release(buf);
return;
}
if (filter) {
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1);
}
if (fp != phar_obj->archive->fp) {
php_stream_close(fp);
}
ZSTR_VAL(buf)[len] = '\0';
ZSTR_LEN(buf) = len;
RETVAL_STR(buf);
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,906 | PHP_METHOD(Phar, getMetadata)
{
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
if (phar_obj->archive->is_persistent) {
char *buf = estrndup((char *) Z_PTR(phar_obj->archive->metadata), phar_obj->archive->metadata_len);
/* assume success, we would have failed before */
phar_parse_metadata(&buf, return_value, phar_obj->archive->metadata_len);
efree(buf);
} else {
ZVAL_COPY(return_value, &phar_obj->archive->metadata);
}
}
}
| Exec Code | 0 | PHP_METHOD(Phar, getMetadata)
{
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
if (phar_obj->archive->is_persistent) {
char *buf = estrndup((char *) Z_PTR(phar_obj->archive->metadata), phar_obj->archive->metadata_len);
/* assume success, we would have failed before */
phar_parse_metadata(&buf, return_value, phar_obj->archive->metadata_len);
efree(buf);
} else {
ZVAL_COPY(return_value, &phar_obj->archive->metadata);
}
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,907 | PHP_METHOD(Phar, setMetadata)
{
char *error;
zval *metadata;
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) {
return;
}
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
zval_ptr_dtor(&phar_obj->archive->metadata);
ZVAL_UNDEF(&phar_obj->archive->metadata);
}
ZVAL_COPY(&phar_obj->archive->metadata, metadata);
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
| Exec Code | 0 | PHP_METHOD(Phar, setMetadata)
{
char *error;
zval *metadata;
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) {
return;
}
if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname);
return;
}
if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
zval_ptr_dtor(&phar_obj->archive->metadata);
ZVAL_UNDEF(&phar_obj->archive->metadata);
}
ZVAL_COPY(&phar_obj->archive->metadata, metadata);
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,908 | PHP_METHOD(Phar, delMetadata)
{
char *error;
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
zval_ptr_dtor(&phar_obj->archive->metadata);
ZVAL_UNDEF(&phar_obj->archive->metadata);
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
RETURN_FALSE;
} else {
RETURN_TRUE;
}
} else {
RETURN_TRUE;
}
}
| Exec Code | 0 | PHP_METHOD(Phar, delMetadata)
{
char *error;
PHAR_ARCHIVE_OBJECT();
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
return;
}
if (Z_TYPE(phar_obj->archive->metadata) != IS_UNDEF) {
zval_ptr_dtor(&phar_obj->archive->metadata);
ZVAL_UNDEF(&phar_obj->archive->metadata);
phar_obj->archive->is_modified = 1;
phar_flush(phar_obj->archive, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
RETURN_FALSE;
} else {
RETURN_TRUE;
}
} else {
RETURN_TRUE;
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,909 | PHP_METHOD(PharFileInfo, getCompressedSize)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(entry_obj->entry->compressed_filesize);
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, getCompressedSize)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(entry_obj->entry->compressed_filesize);
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,910 | PHP_METHOD(PharFileInfo, isCRCChecked)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(entry_obj->entry->is_crc_checked);
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, isCRCChecked)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(entry_obj->entry->is_crc_checked);
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,911 | PHP_METHOD(PharFileInfo, chmod)
{
char *error;
zend_long perms;
PHAR_ENTRY_OBJECT();
if (entry_obj->entry->is_temp_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->entry->filename); \
return;
}
if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
zend_throw_exception_ex(phar_ce_PharException, 0, "Cannot modify permissions for file \"%s\" in phar \"%s\", write operations are prohibited", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &perms) == FAILURE) {
return;
}
if (entry_obj->entry->is_persistent) {
phar_archive_data *phar = entry_obj->entry->phar;
if (FAILURE == phar_copy_on_write(&phar)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
/* clear permissions */
entry_obj->entry->flags &= ~PHAR_ENT_PERM_MASK;
perms &= 0777;
entry_obj->entry->flags |= perms;
entry_obj->entry->old_flags = entry_obj->entry->flags;
entry_obj->entry->phar->is_modified = 1;
entry_obj->entry->is_modified = 1;
/* hackish cache in php_stat needs to be cleared */
/* if this code fails to work, check main/streams/streams.c, _php_stream_stat_path */
if (BG(CurrentLStatFile)) {
efree(BG(CurrentLStatFile));
}
if (BG(CurrentStatFile)) {
efree(BG(CurrentStatFile));
}
BG(CurrentLStatFile) = NULL;
BG(CurrentStatFile) = NULL;
phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, chmod)
{
char *error;
zend_long perms;
PHAR_ENTRY_OBJECT();
if (entry_obj->entry->is_temp_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->entry->filename); \
return;
}
if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
zend_throw_exception_ex(phar_ce_PharException, 0, "Cannot modify permissions for file \"%s\" in phar \"%s\", write operations are prohibited", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &perms) == FAILURE) {
return;
}
if (entry_obj->entry->is_persistent) {
phar_archive_data *phar = entry_obj->entry->phar;
if (FAILURE == phar_copy_on_write(&phar)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
/* clear permissions */
entry_obj->entry->flags &= ~PHAR_ENT_PERM_MASK;
perms &= 0777;
entry_obj->entry->flags |= perms;
entry_obj->entry->old_flags = entry_obj->entry->flags;
entry_obj->entry->phar->is_modified = 1;
entry_obj->entry->is_modified = 1;
/* hackish cache in php_stat needs to be cleared */
/* if this code fails to work, check main/streams/streams.c, _php_stream_stat_path */
if (BG(CurrentLStatFile)) {
efree(BG(CurrentLStatFile));
}
if (BG(CurrentStatFile)) {
efree(BG(CurrentStatFile));
}
BG(CurrentLStatFile) = NULL;
BG(CurrentStatFile) = NULL;
phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,912 | PHP_METHOD(PharFileInfo, hasMetadata)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF);
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, hasMetadata)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF);
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,913 | PHP_METHOD(PharFileInfo, getMetadata)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF) {
if (entry_obj->entry->is_persistent) {
char *buf = estrndup((char *) Z_PTR(entry_obj->entry->metadata), entry_obj->entry->metadata_len);
/* assume success, we would have failed before */
phar_parse_metadata(&buf, return_value, entry_obj->entry->metadata_len);
efree(buf);
} else {
ZVAL_COPY(return_value, &entry_obj->entry->metadata);
}
}
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, getMetadata)
{
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (Z_TYPE(entry_obj->entry->metadata) != IS_UNDEF) {
if (entry_obj->entry->is_persistent) {
char *buf = estrndup((char *) Z_PTR(entry_obj->entry->metadata), entry_obj->entry->metadata_len);
/* assume success, we would have failed before */
phar_parse_metadata(&buf, return_value, entry_obj->entry->metadata_len);
efree(buf);
} else {
ZVAL_COPY(return_value, &entry_obj->entry->metadata);
}
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,914 | PHP_METHOD(PharFileInfo, getContent)
{
char *error;
php_stream *fp;
phar_entry_info *link;
zend_string *str;
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (entry_obj->entry->is_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
link = phar_get_link_source(entry_obj->entry);
if (!link) {
link = entry_obj->entry;
}
if (SUCCESS != phar_open_entry_fp(link, &error, 0)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
if (!(fp = phar_get_efp(link, 0))) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
phar_seek_efp(link, 0, SEEK_SET, 0, 0);
str = php_stream_copy_to_mem(fp, link->uncompressed_filesize, 0);
if (str) {
RETURN_STR(str);
} else {
RETURN_EMPTY_STRING();
}
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, getContent)
{
char *error;
php_stream *fp;
phar_entry_info *link;
zend_string *str;
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (entry_obj->entry->is_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
link = phar_get_link_source(entry_obj->entry);
if (!link) {
link = entry_obj->entry;
}
if (SUCCESS != phar_open_entry_fp(link, &error, 0)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
if (!(fp = phar_get_efp(link, 0))) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", entry_obj->entry->filename, entry_obj->entry->phar->fname);
return;
}
phar_seek_efp(link, 0, SEEK_SET, 0, 0);
str = php_stream_copy_to_mem(fp, link->uncompressed_filesize, 0);
if (str) {
RETURN_STR(str);
} else {
RETURN_EMPTY_STRING();
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,915 | PHP_METHOD(PharFileInfo, compress)
{
zend_long method;
char *error;
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
return;
}
if (entry_obj->entry->is_tar) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with Gzip compression, not possible with tar-based phar archives");
return;
}
if (entry_obj->entry->is_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a directory, cannot set compression"); \
return;
}
if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
if (entry_obj->entry->is_deleted) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress deleted file");
return;
}
if (entry_obj->entry->is_persistent) {
phar_archive_data *phar = entry_obj->entry->phar;
if (FAILURE == phar_copy_on_write(&phar)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) {
RETURN_TRUE;
}
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with gzip compression, file is already compressed with bzip2 compression and bz2 extension is not enabled, cannot decompress");
return;
}
/* decompress this file indirectly */
if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
}
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with gzip compression, zlib extension is not enabled");
return;
}
entry_obj->entry->old_flags = entry_obj->entry->flags;
entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
RETURN_TRUE;
}
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with bzip2 compression, file is already compressed with gzip compression and zlib extension is not enabled, cannot decompress");
return;
}
/* decompress this file indirectly */
if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
}
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with bzip2 compression, bz2 extension is not enabled");
return;
}
entry_obj->entry->old_flags = entry_obj->entry->flags;
entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_BZ2;
break;
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Unknown compression type specified"); \
}
entry_obj->entry->phar->is_modified = 1;
entry_obj->entry->is_modified = 1;
phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
RETURN_TRUE;
}
| Exec Code | 0 | PHP_METHOD(PharFileInfo, compress)
{
zend_long method;
char *error;
PHAR_ENTRY_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
return;
}
if (entry_obj->entry->is_tar) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with Gzip compression, not possible with tar-based phar archives");
return;
}
if (entry_obj->entry->is_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Phar entry is a directory, cannot set compression"); \
return;
}
if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar is readonly, cannot change compression");
return;
}
if (entry_obj->entry->is_deleted) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress deleted file");
return;
}
if (entry_obj->entry->is_persistent) {
phar_archive_data *phar = entry_obj->entry->phar;
if (FAILURE == phar_copy_on_write(&phar)) {
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar->fname);
return;
}
/* re-populate after copy-on-write */
entry_obj->entry = zend_hash_str_find_ptr(&phar->manifest, entry_obj->entry->filename, entry_obj->entry->filename_len);
}
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) {
RETURN_TRUE;
}
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with gzip compression, file is already compressed with bzip2 compression and bz2 extension is not enabled, cannot decompress");
return;
}
/* decompress this file indirectly */
if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
}
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with gzip compression, zlib extension is not enabled");
return;
}
entry_obj->entry->old_flags = entry_obj->entry->flags;
entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_GZ;
break;
case PHAR_ENT_COMPRESSED_BZ2:
if (entry_obj->entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
RETURN_TRUE;
}
if ((entry_obj->entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with bzip2 compression, file is already compressed with gzip compression and zlib extension is not enabled, cannot decompress");
return;
}
/* decompress this file indirectly */
if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error);
efree(error);
return;
}
}
if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0,
"Cannot compress with bzip2 compression, bz2 extension is not enabled");
return;
}
entry_obj->entry->old_flags = entry_obj->entry->flags;
entry_obj->entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
entry_obj->entry->flags |= PHAR_ENT_COMPRESSED_BZ2;
break;
default:
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \
"Unknown compression type specified"); \
}
entry_obj->entry->phar->is_modified = 1;
entry_obj->entry->is_modified = 1;
phar_flush(entry_obj->entry->phar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
RETURN_TRUE;
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,916 | static void phar_add_file(phar_archive_data **pphar, char *filename, int filename_len, char *cont_str, size_t cont_len, zval *zresource)
{
char *error;
size_t contents_len;
phar_entry_data *data;
php_stream *contents_file;
if (filename_len >= sizeof(".phar")-1 && !memcmp(filename, ".phar", sizeof(".phar")-1) && (filename[5] == '/' || filename[5] == '\\' || filename[5] == '\0')) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create any files in magic \".phar\" directory", (*pphar)->fname);
return;
}
if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, 1))) {
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created: %s", filename, error);
efree(error);
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created", filename);
}
return;
} else {
if (error) {
efree(error);
}
if (!data->internal_file->is_dir) {
if (cont_str) {
contents_len = php_stream_write(data->fp, cont_str, cont_len);
if (contents_len != cont_len) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s could not be written to", filename);
return;
}
} else {
if (!(php_stream_from_zval_no_verify(contents_file, zresource))) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s could not be written to", filename);
return;
}
php_stream_copy_to_stream_ex(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len);
}
data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len;
}
/* check for copy-on-write */
if (pphar[0] != data->phar) {
*pphar = data->phar;
}
phar_entry_delref(data);
phar_flush(*pphar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
}
| Exec Code | 0 | static void phar_add_file(phar_archive_data **pphar, char *filename, int filename_len, char *cont_str, size_t cont_len, zval *zresource)
{
char *error;
size_t contents_len;
phar_entry_data *data;
php_stream *contents_file;
if (filename_len >= sizeof(".phar")-1 && !memcmp(filename, ".phar", sizeof(".phar")-1) && (filename[5] == '/' || filename[5] == '\\' || filename[5] == '\0')) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create any files in magic \".phar\" directory", (*pphar)->fname);
return;
}
if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, 1))) {
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created: %s", filename, error);
efree(error);
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created", filename);
}
return;
} else {
if (error) {
efree(error);
}
if (!data->internal_file->is_dir) {
if (cont_str) {
contents_len = php_stream_write(data->fp, cont_str, cont_len);
if (contents_len != cont_len) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s could not be written to", filename);
return;
}
} else {
if (!(php_stream_from_zval_no_verify(contents_file, zresource))) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s could not be written to", filename);
return;
}
php_stream_copy_to_stream_ex(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len);
}
data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len;
}
/* check for copy-on-write */
if (pphar[0] != data->phar) {
*pphar = data->phar;
}
phar_entry_delref(data);
phar_flush(*pphar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,917 | static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry, newentry;
zend_object *ret;
/* invalidate phar cache */
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
phar = (phar_archive_data *) ecalloc(1, sizeof(phar_archive_data));
/* set whole-archive compression and type from parameter */
phar->flags = flags;
phar->is_data = source->is_data;
switch (convert) {
case PHAR_FORMAT_TAR:
phar->is_tar = 1;
break;
case PHAR_FORMAT_ZIP:
phar->is_zip = 1;
break;
default:
phar->is_data = 0;
break;
}
zend_hash_init(&(phar->manifest), sizeof(phar_entry_info),
zend_get_hash_value, destroy_phar_manifest_entry, 0);
zend_hash_init(&phar->mounted_dirs, sizeof(char *),
zend_get_hash_value, NULL, 0);
zend_hash_init(&phar->virtual_dirs, sizeof(char *),
zend_get_hash_value, NULL, 0);
phar->fp = php_stream_fopen_tmpfile();
if (phar->fp == NULL) {
zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file");
return NULL;
}
phar->fname = source->fname;
phar->fname_len = source->fname_len;
phar->is_temporary_alias = source->is_temporary_alias;
phar->alias = source->alias;
if (Z_TYPE(source->metadata) != IS_UNDEF) {
ZVAL_DUP(&phar->metadata, &source->metadata);
phar->metadata_len = 0;
}
/* first copy each file's uncompressed contents to a temporary file and set per-file flags */
ZEND_HASH_FOREACH_PTR(&source->manifest, entry) {
newentry = *entry;
if (newentry.link) {
newentry.link = estrdup(newentry.link);
goto no_copy;
}
if (newentry.tmp) {
newentry.tmp = estrdup(newentry.tmp);
goto no_copy;
}
newentry.metadata_str.s = NULL;
if (FAILURE == phar_copy_file_contents(&newentry, phar->fp)) {
zend_hash_destroy(&(phar->manifest));
php_stream_close(phar->fp);
efree(phar);
/* exception already thrown */
return NULL;
}
no_copy:
newentry.filename = estrndup(newentry.filename, newentry.filename_len);
if (Z_TYPE(newentry.metadata) != IS_UNDEF) {
zval_copy_ctor(&newentry.metadata);
newentry.metadata_str.s = NULL;
}
newentry.is_zip = phar->is_zip;
newentry.is_tar = phar->is_tar;
if (newentry.is_tar) {
newentry.tar_type = (entry->is_dir ? TAR_DIR : TAR_FILE);
}
newentry.is_modified = 1;
newentry.phar = phar;
newentry.old_flags = newentry.flags & ~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */
phar_set_inode(&newentry);
zend_hash_str_add_mem(&(phar->manifest), newentry.filename, newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info));
phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len);
} ZEND_HASH_FOREACH_END();
if ((ret = phar_rename_archive(&phar, ext, 0))) {
return ret;
} else {
if(phar != NULL) {
zend_hash_destroy(&(phar->manifest));
zend_hash_destroy(&(phar->mounted_dirs));
zend_hash_destroy(&(phar->virtual_dirs));
if (phar->fp) {
php_stream_close(phar->fp);
}
efree(phar->fname);
efree(phar);
}
return NULL;
}
}
/* }}} */
| Exec Code | 0 | static zend_object *phar_convert_to_other(phar_archive_data *source, int convert, char *ext, php_uint32 flags) /* {{{ */
{
phar_archive_data *phar;
phar_entry_info *entry, newentry;
zend_object *ret;
/* invalidate phar cache */
PHAR_G(last_phar) = NULL;
PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL;
phar = (phar_archive_data *) ecalloc(1, sizeof(phar_archive_data));
/* set whole-archive compression and type from parameter */
phar->flags = flags;
phar->is_data = source->is_data;
switch (convert) {
case PHAR_FORMAT_TAR:
phar->is_tar = 1;
break;
case PHAR_FORMAT_ZIP:
phar->is_zip = 1;
break;
default:
phar->is_data = 0;
break;
}
zend_hash_init(&(phar->manifest), sizeof(phar_entry_info),
zend_get_hash_value, destroy_phar_manifest_entry, 0);
zend_hash_init(&phar->mounted_dirs, sizeof(char *),
zend_get_hash_value, NULL, 0);
zend_hash_init(&phar->virtual_dirs, sizeof(char *),
zend_get_hash_value, NULL, 0);
phar->fp = php_stream_fopen_tmpfile();
if (phar->fp == NULL) {
zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file");
return NULL;
}
phar->fname = source->fname;
phar->fname_len = source->fname_len;
phar->is_temporary_alias = source->is_temporary_alias;
phar->alias = source->alias;
if (Z_TYPE(source->metadata) != IS_UNDEF) {
ZVAL_DUP(&phar->metadata, &source->metadata);
phar->metadata_len = 0;
}
/* first copy each file's uncompressed contents to a temporary file and set per-file flags */
ZEND_HASH_FOREACH_PTR(&source->manifest, entry) {
newentry = *entry;
if (newentry.link) {
newentry.link = estrdup(newentry.link);
goto no_copy;
}
if (newentry.tmp) {
newentry.tmp = estrdup(newentry.tmp);
goto no_copy;
}
newentry.metadata_str.s = NULL;
if (FAILURE == phar_copy_file_contents(&newentry, phar->fp)) {
zend_hash_destroy(&(phar->manifest));
php_stream_close(phar->fp);
efree(phar);
/* exception already thrown */
return NULL;
}
no_copy:
newentry.filename = estrndup(newentry.filename, newentry.filename_len);
if (Z_TYPE(newentry.metadata) != IS_UNDEF) {
zval_copy_ctor(&newentry.metadata);
newentry.metadata_str.s = NULL;
}
newentry.is_zip = phar->is_zip;
newentry.is_tar = phar->is_tar;
if (newentry.is_tar) {
newentry.tar_type = (entry->is_dir ? TAR_DIR : TAR_FILE);
}
newentry.is_modified = 1;
newentry.phar = phar;
newentry.old_flags = newentry.flags & ~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */
phar_set_inode(&newentry);
zend_hash_str_add_mem(&(phar->manifest), newentry.filename, newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info));
phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len);
} ZEND_HASH_FOREACH_END();
if ((ret = phar_rename_archive(&phar, ext, 0))) {
return ret;
} else {
if(phar != NULL) {
zend_hash_destroy(&(phar->manifest));
zend_hash_destroy(&(phar->mounted_dirs));
zend_hash_destroy(&(phar->virtual_dirs));
if (phar->fp) {
php_stream_close(phar->fp);
}
efree(phar->fname);
efree(phar);
}
return NULL;
}
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,918 | static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp) /* {{{ */
{
char *error;
zend_off_t offset;
phar_entry_info *link;
if (FAILURE == phar_open_entry_fp(entry, &error, 1)) {
if (error) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents: %s", entry->phar->fname, entry->filename, error);
efree(error);
} else {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents", entry->phar->fname, entry->filename);
}
return FAILURE;
}
/* copy old contents in entirety */
phar_seek_efp(entry, 0, SEEK_SET, 0, 1);
offset = php_stream_tell(fp);
link = phar_get_link_source(entry);
if (!link) {
link = entry;
}
if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), fp, link->uncompressed_filesize, NULL)) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", entry->phar->fname, entry->filename);
return FAILURE;
}
if (entry->fp_type == PHAR_MOD) {
/* save for potential restore on error */
entry->cfp = entry->fp;
entry->fp = NULL;
}
/* set new location of file contents */
entry->fp_type = PHAR_FP;
entry->offset = offset;
return SUCCESS;
}
/* }}} */
| Exec Code | 0 | static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp) /* {{{ */
{
char *error;
zend_off_t offset;
phar_entry_info *link;
if (FAILURE == phar_open_entry_fp(entry, &error, 1)) {
if (error) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents: %s", entry->phar->fname, entry->filename, error);
efree(error);
} else {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents", entry->phar->fname, entry->filename);
}
return FAILURE;
}
/* copy old contents in entirety */
phar_seek_efp(entry, 0, SEEK_SET, 0, 1);
offset = php_stream_tell(fp);
link = phar_get_link_source(entry);
if (!link) {
link = entry;
}
if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), fp, link->uncompressed_filesize, NULL)) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", entry->phar->fname, entry->filename);
return FAILURE;
}
if (entry->fp_type == PHAR_MOD) {
/* save for potential restore on error */
entry->cfp = entry->fp;
entry->fp = NULL;
}
/* set new location of file contents */
entry->fp_type = PHAR_FP;
entry->offset = offset;
return SUCCESS;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,919 | static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, char *f404, size_t f404_len, char *entry, size_t entry_len) /* {{{ */
{
sapi_header_line ctr = {0};
phar_entry_info *info;
if (phar && f404_len) {
info = phar_get_entry_info(phar, f404, f404_len, NULL, 1);
if (info) {
phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0);
return;
}
}
ctr.response_code = 404;
ctr.line_len = sizeof("HTTP/1.0 404 Not Found")-1;
ctr.line = "HTTP/1.0 404 Not Found";
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
sapi_send_headers();
PHPWRITE("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ", sizeof("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ") - 1);
PHPWRITE(entry, entry_len);
PHPWRITE(" Not Found</h1>\n </body>\n</html>", sizeof(" Not Found</h1>\n </body>\n</html>") - 1);
}
/* }}} */
| Exec Code | 0 | static void phar_do_404(phar_archive_data *phar, char *fname, int fname_len, char *f404, size_t f404_len, char *entry, size_t entry_len) /* {{{ */
{
sapi_header_line ctr = {0};
phar_entry_info *info;
if (phar && f404_len) {
info = phar_get_entry_info(phar, f404, f404_len, NULL, 1);
if (info) {
phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0);
return;
}
}
ctr.response_code = 404;
ctr.line_len = sizeof("HTTP/1.0 404 Not Found")-1;
ctr.line = "HTTP/1.0 404 Not Found";
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
sapi_send_headers();
PHPWRITE("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ", sizeof("<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File ") - 1);
PHPWRITE(entry, entry_len);
PHPWRITE(" Not Found</h1>\n </body>\n</html>", sizeof(" Not Found</h1>\n </body>\n</html>") - 1);
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,920 | static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, int dest_len, char **error) /* {{{ */
{
php_stream_statbuf ssb;
int len;
php_stream *fp;
char *fullpath;
const char *slash;
mode_t mode;
cwd_state new_state;
char *filename;
size_t filename_len;
if (entry->is_mounted) {
/* silently ignore mounted entries */
return SUCCESS;
}
if (entry->filename_len >= sizeof(".phar")-1 && !memcmp(entry->filename, ".phar", sizeof(".phar")-1)) {
return SUCCESS;
}
/* strip .. from path and restrict it to be under dest directory */
new_state.cwd = (char*)emalloc(2);
new_state.cwd[0] = DEFAULT_SLASH;
new_state.cwd[1] = '\0';
new_state.cwd_length = 1;
if (virtual_file_ex(&new_state, entry->filename, NULL, CWD_EXPAND) != 0 ||
new_state.cwd_length <= 1) {
if (EINVAL == errno && entry->filename_len > 50) {
char *tmp = estrndup(entry->filename, 50);
spprintf(error, 4096, "Cannot extract \"%s...\" to \"%s...\", extracted filename is too long for filesystem", tmp, dest);
efree(tmp);
} else {
spprintf(error, 4096, "Cannot extract \"%s\", internal error", entry->filename);
}
efree(new_state.cwd);
return FAILURE;
}
filename = new_state.cwd + 1;
filename_len = new_state.cwd_length - 1;
#ifdef PHP_WIN32
/* unixify the path back, otherwise non zip formats might be broken */
{
int cnt = filename_len;
do {
if ('\\' == filename[cnt]) {
filename[cnt] = '/';
}
} while (cnt-- >= 0);
}
#endif
len = spprintf(&fullpath, 0, "%s/%s", dest, filename);
if (len >= MAXPATHLEN) {
char *tmp;
/* truncate for error message */
fullpath[50] = '\0';
if (entry->filename_len > 50) {
tmp = estrndup(entry->filename, 50);
spprintf(error, 4096, "Cannot extract \"%s...\" to \"%s...\", extracted filename is too long for filesystem", tmp, fullpath);
efree(tmp);
} else {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s...\", extracted filename is too long for filesystem", entry->filename, fullpath);
}
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
if (!len) {
spprintf(error, 4096, "Cannot extract \"%s\", internal error", entry->filename);
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
if (PHAR_OPENBASEDIR_CHECKPATH(fullpath)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", openbasedir/safe mode restrictions in effect", entry->filename, fullpath);
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
/* let see if the path already exists */
if (!overwrite && SUCCESS == php_stream_stat_path(fullpath, &ssb)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", path already exists", entry->filename, fullpath);
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
/* perform dirname */
slash = zend_memrchr(filename, '/', filename_len);
if (slash) {
fullpath[dest_len + (slash - filename) + 1] = '\0';
} else {
fullpath[dest_len] = '\0';
}
if (FAILURE == php_stream_stat_path(fullpath, &ssb)) {
if (entry->is_dir) {
if (!php_stream_mkdir(fullpath, entry->flags & PHAR_ENT_PERM_MASK, PHP_STREAM_MKDIR_RECURSIVE, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\", could not create directory \"%s\"", entry->filename, fullpath);
efree(fullpath);
free(new_state.cwd);
return FAILURE;
}
} else {
if (!php_stream_mkdir(fullpath, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\", could not create directory \"%s\"", entry->filename, fullpath);
efree(fullpath);
free(new_state.cwd);
return FAILURE;
}
}
}
if (slash) {
fullpath[dest_len + (slash - filename) + 1] = '/';
} else {
fullpath[dest_len] = '/';
}
filename = NULL;
efree(new_state.cwd);
/* it is a standalone directory, job done */
if (entry->is_dir) {
efree(fullpath);
return SUCCESS;
}
#if PHP_API_VERSION < 20100412
fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
#else
fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
#endif
if (!fp) {
spprintf(error, 4096, "Cannot extract \"%s\", could not open for writing \"%s\"", entry->filename, fullpath);
efree(fullpath);
return FAILURE;
}
if (!phar_get_efp(entry, 0)) {
if (FAILURE == phar_open_entry_fp(entry, error, 1)) {
if (error) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer: %s", entry->filename, fullpath, *error);
} else {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer", entry->filename, fullpath);
}
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
}
if (FAILURE == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to seek internal file pointer", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp, entry->uncompressed_filesize, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying contents failed", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
php_stream_close(fp);
mode = (mode_t) entry->flags & PHAR_ENT_PERM_MASK;
if (FAILURE == VCWD_CHMOD(fullpath, mode)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", setting file permissions failed", entry->filename, fullpath);
efree(fullpath);
return FAILURE;
}
efree(fullpath);
return SUCCESS;
}
/* }}} */
| Exec Code | 0 | static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char *dest, int dest_len, char **error) /* {{{ */
{
php_stream_statbuf ssb;
int len;
php_stream *fp;
char *fullpath;
const char *slash;
mode_t mode;
cwd_state new_state;
char *filename;
size_t filename_len;
if (entry->is_mounted) {
/* silently ignore mounted entries */
return SUCCESS;
}
if (entry->filename_len >= sizeof(".phar")-1 && !memcmp(entry->filename, ".phar", sizeof(".phar")-1)) {
return SUCCESS;
}
/* strip .. from path and restrict it to be under dest directory */
new_state.cwd = (char*)emalloc(2);
new_state.cwd[0] = DEFAULT_SLASH;
new_state.cwd[1] = '\0';
new_state.cwd_length = 1;
if (virtual_file_ex(&new_state, entry->filename, NULL, CWD_EXPAND) != 0 ||
new_state.cwd_length <= 1) {
if (EINVAL == errno && entry->filename_len > 50) {
char *tmp = estrndup(entry->filename, 50);
spprintf(error, 4096, "Cannot extract \"%s...\" to \"%s...\", extracted filename is too long for filesystem", tmp, dest);
efree(tmp);
} else {
spprintf(error, 4096, "Cannot extract \"%s\", internal error", entry->filename);
}
efree(new_state.cwd);
return FAILURE;
}
filename = new_state.cwd + 1;
filename_len = new_state.cwd_length - 1;
#ifdef PHP_WIN32
/* unixify the path back, otherwise non zip formats might be broken */
{
int cnt = filename_len;
do {
if ('\\' == filename[cnt]) {
filename[cnt] = '/';
}
} while (cnt-- >= 0);
}
#endif
len = spprintf(&fullpath, 0, "%s/%s", dest, filename);
if (len >= MAXPATHLEN) {
char *tmp;
/* truncate for error message */
fullpath[50] = '\0';
if (entry->filename_len > 50) {
tmp = estrndup(entry->filename, 50);
spprintf(error, 4096, "Cannot extract \"%s...\" to \"%s...\", extracted filename is too long for filesystem", tmp, fullpath);
efree(tmp);
} else {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s...\", extracted filename is too long for filesystem", entry->filename, fullpath);
}
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
if (!len) {
spprintf(error, 4096, "Cannot extract \"%s\", internal error", entry->filename);
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
if (PHAR_OPENBASEDIR_CHECKPATH(fullpath)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", openbasedir/safe mode restrictions in effect", entry->filename, fullpath);
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
/* let see if the path already exists */
if (!overwrite && SUCCESS == php_stream_stat_path(fullpath, &ssb)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", path already exists", entry->filename, fullpath);
efree(fullpath);
efree(new_state.cwd);
return FAILURE;
}
/* perform dirname */
slash = zend_memrchr(filename, '/', filename_len);
if (slash) {
fullpath[dest_len + (slash - filename) + 1] = '\0';
} else {
fullpath[dest_len] = '\0';
}
if (FAILURE == php_stream_stat_path(fullpath, &ssb)) {
if (entry->is_dir) {
if (!php_stream_mkdir(fullpath, entry->flags & PHAR_ENT_PERM_MASK, PHP_STREAM_MKDIR_RECURSIVE, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\", could not create directory \"%s\"", entry->filename, fullpath);
efree(fullpath);
free(new_state.cwd);
return FAILURE;
}
} else {
if (!php_stream_mkdir(fullpath, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\", could not create directory \"%s\"", entry->filename, fullpath);
efree(fullpath);
free(new_state.cwd);
return FAILURE;
}
}
}
if (slash) {
fullpath[dest_len + (slash - filename) + 1] = '/';
} else {
fullpath[dest_len] = '/';
}
filename = NULL;
efree(new_state.cwd);
/* it is a standalone directory, job done */
if (entry->is_dir) {
efree(fullpath);
return SUCCESS;
}
#if PHP_API_VERSION < 20100412
fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
#else
fp = php_stream_open_wrapper(fullpath, "w+b", REPORT_ERRORS, NULL);
#endif
if (!fp) {
spprintf(error, 4096, "Cannot extract \"%s\", could not open for writing \"%s\"", entry->filename, fullpath);
efree(fullpath);
return FAILURE;
}
if (!phar_get_efp(entry, 0)) {
if (FAILURE == phar_open_entry_fp(entry, error, 1)) {
if (error) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer: %s", entry->filename, fullpath, *error);
} else {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer", entry->filename, fullpath);
}
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
}
if (FAILURE == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to seek internal file pointer", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp, entry->uncompressed_filesize, NULL)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying contents failed", entry->filename, fullpath);
efree(fullpath);
php_stream_close(fp);
return FAILURE;
}
php_stream_close(fp);
mode = (mode_t) entry->flags & PHAR_ENT_PERM_MASK;
if (FAILURE == VCWD_CHMOD(fullpath, mode)) {
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", setting file permissions failed", entry->filename, fullpath);
efree(fullpath);
return FAILURE;
}
efree(fullpath);
return SUCCESS;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,921 | static int phar_file_type(HashTable *mimes, char *file, char **mime_type) /* {{{ */
{
char *ext;
phar_mime_type *mime;
ext = strrchr(file, '.');
if (!ext) {
*mime_type = "text/plain";
/* no file extension = assume text/plain */
return PHAR_MIME_OTHER;
}
++ext;
if (NULL == (mime = zend_hash_str_find_ptr(mimes, ext, strlen(ext)))) {
*mime_type = "application/octet-stream";
return PHAR_MIME_OTHER;
}
*mime_type = mime->mime;
return mime->type;
}
/* }}} */
| Exec Code | 0 | static int phar_file_type(HashTable *mimes, char *file, char **mime_type) /* {{{ */
{
char *ext;
phar_mime_type *mime;
ext = strrchr(file, '.');
if (!ext) {
*mime_type = "text/plain";
/* no file extension = assume text/plain */
return PHAR_MIME_OTHER;
}
++ext;
if (NULL == (mime = zend_hash_str_find_ptr(mimes, ext, strlen(ext)))) {
*mime_type = "application/octet-stream";
return PHAR_MIME_OTHER;
}
*mime_type = mime->mime;
return mime->type;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,922 | static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len)
{
char *error;
phar_entry_data *data;
if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, dirname, dirname_len, "w+b", 2, &error, 1))) {
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created: %s", dirname, error);
efree(error);
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created", dirname);
}
return;
} else {
if (error) {
efree(error);
}
/* check for copy on write */
if (data->phar != *pphar) {
*pphar = data->phar;
}
phar_entry_delref(data);
phar_flush(*pphar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
}
| Exec Code | 0 | static void phar_mkdir(phar_archive_data **pphar, char *dirname, int dirname_len)
{
char *error;
phar_entry_data *data;
if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, dirname, dirname_len, "w+b", 2, &error, 1))) {
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created: %s", dirname, error);
efree(error);
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created", dirname);
}
return;
} else {
if (error) {
efree(error);
}
/* check for copy on write */
if (data->phar != *pphar) {
*pphar = data->phar;
}
phar_entry_delref(data);
phar_flush(*pphar, 0, 0, 0, &error);
if (error) {
zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error);
efree(error);
}
}
}
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,923 | static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len) /* {{{ */
{
HashTable *_SERVER;
zval *stuff;
char *path_info;
int basename_len = strlen(basename);
int code;
zval temp;
/* "tweak" $_SERVER variables requested in earlier call to Phar::mungServer() */
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_UNDEF) {
return;
}
_SERVER = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);
/* PATH_INFO and PATH_TRANSLATED should always be munged */
if (NULL != (stuff = zend_hash_str_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO")-1))) {
path_info = Z_STRVAL_P(stuff);
code = Z_STRLEN_P(stuff);
if (code > entry_len && !memcmp(path_info, entry, entry_len)) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, path_info + entry_len, request_uri_len);
zend_hash_str_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO")-1, &temp);
}
}
if (NULL != (stuff = zend_hash_str_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1))) {
zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_NEW_STR(stuff, str);
zend_hash_str_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED")-1, &temp);
}
if (!PHAR_G(phar_SERVER_mung_list)) {
return;
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_REQUEST_URI) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI")-1))) {
path_info = Z_STRVAL_P(stuff);
code = Z_STRLEN_P(stuff);
if (code > basename_len && !memcmp(path_info, basename, basename_len)) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, path_info + basename_len, code - basename_len);
zend_hash_str_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI")-1, &temp);
}
}
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_PHP_SELF) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF")-1))) {
path_info = Z_STRVAL_P(stuff);
code = Z_STRLEN_P(stuff);
if (code > basename_len && !memcmp(path_info, basename, basename_len)) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, path_info + basename_len, code - basename_len);
zend_hash_str_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF")-1, &temp);
}
}
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_SCRIPT_NAME) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1))) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, entry, entry_len);
zend_hash_str_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME")-1, &temp);
}
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_SCRIPT_FILENAME) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1))) {
zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_NEW_STR(stuff, str);
zend_hash_str_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME")-1, &temp);
}
}
}
/* }}} */
| Exec Code | 0 | static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len) /* {{{ */
{
HashTable *_SERVER;
zval *stuff;
char *path_info;
int basename_len = strlen(basename);
int code;
zval temp;
/* "tweak" $_SERVER variables requested in earlier call to Phar::mungServer() */
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_UNDEF) {
return;
}
_SERVER = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]);
/* PATH_INFO and PATH_TRANSLATED should always be munged */
if (NULL != (stuff = zend_hash_str_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO")-1))) {
path_info = Z_STRVAL_P(stuff);
code = Z_STRLEN_P(stuff);
if (code > entry_len && !memcmp(path_info, entry, entry_len)) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, path_info + entry_len, request_uri_len);
zend_hash_str_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO")-1, &temp);
}
}
if (NULL != (stuff = zend_hash_str_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1))) {
zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_NEW_STR(stuff, str);
zend_hash_str_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED")-1, &temp);
}
if (!PHAR_G(phar_SERVER_mung_list)) {
return;
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_REQUEST_URI) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI")-1))) {
path_info = Z_STRVAL_P(stuff);
code = Z_STRLEN_P(stuff);
if (code > basename_len && !memcmp(path_info, basename, basename_len)) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, path_info + basename_len, code - basename_len);
zend_hash_str_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI")-1, &temp);
}
}
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_PHP_SELF) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF")-1))) {
path_info = Z_STRVAL_P(stuff);
code = Z_STRLEN_P(stuff);
if (code > basename_len && !memcmp(path_info, basename, basename_len)) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, path_info + basename_len, code - basename_len);
zend_hash_str_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF")-1, &temp);
}
}
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_SCRIPT_NAME) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1))) {
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_STRINGL(stuff, entry, entry_len);
zend_hash_str_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME")-1, &temp);
}
}
if (PHAR_G(phar_SERVER_mung_list) & PHAR_MUNG_SCRIPT_FILENAME) {
if (NULL != (stuff = zend_hash_str_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1))) {
zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
ZVAL_STR(&temp, Z_STR_P(stuff));
ZVAL_NEW_STR(stuff, str);
zend_hash_str_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME")-1, &temp);
}
}
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,924 | void phar_object_init(void) /* {{{ */
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods);
phar_ce_PharException = zend_register_internal_class_ex(&ce, zend_ce_exception);
#if HAVE_SPL
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
zend_class_implements(phar_ce_archive, 2, spl_ce_Countable, zend_ce_arrayaccess);
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
zend_class_implements(phar_ce_data, 2, spl_ce_Countable, zend_ce_arrayaccess);
INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo);
#else
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
phar_ce_archive = zend_register_internal_class(&ce);
phar_ce_archive->ce_flags |= ZEND_ACC_FINAL;
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
phar_ce_data = zend_register_internal_class(&ce);
phar_ce_data->ce_flags |= ZEND_ACC_FINAL;
#endif
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "GZ", PHAR_ENT_COMPRESSED_GZ)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "NONE", PHAR_ENT_COMPRESSED_NONE)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHAR", PHAR_FORMAT_PHAR)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "TAR", PHAR_FORMAT_TAR)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "ZIP", PHAR_FORMAT_ZIP)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "COMPRESSED", PHAR_ENT_COMPRESSION_MASK)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHP", PHAR_MIME_PHP)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHPS", PHAR_MIME_PHPS)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "MD5", PHAR_SIG_MD5)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "OPENSSL", PHAR_SIG_OPENSSL)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA1", PHAR_SIG_SHA1)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA256", PHAR_SIG_SHA256)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA512", PHAR_SIG_SHA512)
}
/* }}} */
| Exec Code | 0 | void phar_object_init(void) /* {{{ */
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods);
phar_ce_PharException = zend_register_internal_class_ex(&ce, zend_ce_exception);
#if HAVE_SPL
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
zend_class_implements(phar_ce_archive, 2, spl_ce_Countable, zend_ce_arrayaccess);
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
zend_class_implements(phar_ce_data, 2, spl_ce_Countable, zend_ce_arrayaccess);
INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo);
#else
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
phar_ce_archive = zend_register_internal_class(&ce);
phar_ce_archive->ce_flags |= ZEND_ACC_FINAL;
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
phar_ce_data = zend_register_internal_class(&ce);
phar_ce_data->ce_flags |= ZEND_ACC_FINAL;
#endif
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "GZ", PHAR_ENT_COMPRESSED_GZ)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "NONE", PHAR_ENT_COMPRESSED_NONE)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHAR", PHAR_FORMAT_PHAR)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "TAR", PHAR_FORMAT_TAR)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "ZIP", PHAR_FORMAT_ZIP)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "COMPRESSED", PHAR_ENT_COMPRESSION_MASK)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHP", PHAR_MIME_PHP)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PHPS", PHAR_MIME_PHPS)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "MD5", PHAR_SIG_MD5)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "OPENSSL", PHAR_SIG_OPENSSL)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA1", PHAR_SIG_SHA1)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA256", PHAR_SIG_SHA256)
REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA512", PHAR_SIG_SHA512)
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,925 | static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len) /* {{{ */
{
char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL;
int e_len = *entry_len - 1, u_len = 0;
phar_archive_data *pphar;
/* we already know we can retrieve the phar if we reach here */
pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len);
if (!pphar && PHAR_G(manifest_cached)) {
pphar = zend_hash_str_find_ptr(&cached_phars, fname, fname_len);
}
do {
if (zend_hash_str_exists(&(pphar->manifest), e, e_len)) {
if (u) {
u[0] = '/';
*ru = estrndup(u, u_len+1);
++u_len;
u[0] = '\0';
} else {
*ru = NULL;
}
*ru_len = u_len;
*entry_len = e_len + 1;
return;
}
if (u) {
u1 = strrchr(e, '/');
u[0] = '/';
saveu = u;
e_len += u_len + 1;
u = u1;
if (!u) {
return;
}
} else {
u = strrchr(e, '/');
if (!u) {
if (saveu) {
saveu[0] = '/';
}
return;
}
}
u[0] = '\0';
u_len = strlen(u + 1);
e_len -= u_len + 1;
if (e_len < 0) {
if (saveu) {
saveu[0] = '/';
}
return;
}
} while (1);
}
/* }}} */
| Exec Code | 0 | static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len) /* {{{ */
{
char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL;
int e_len = *entry_len - 1, u_len = 0;
phar_archive_data *pphar;
/* we already know we can retrieve the phar if we reach here */
pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len);
if (!pphar && PHAR_G(manifest_cached)) {
pphar = zend_hash_str_find_ptr(&cached_phars, fname, fname_len);
}
do {
if (zend_hash_str_exists(&(pphar->manifest), e, e_len)) {
if (u) {
u[0] = '/';
*ru = estrndup(u, u_len+1);
++u_len;
u[0] = '\0';
} else {
*ru = NULL;
}
*ru_len = u_len;
*entry_len = e_len + 1;
return;
}
if (u) {
u1 = strrchr(e, '/');
u[0] = '/';
saveu = u;
e_len += u_len + 1;
u = u1;
if (!u) {
return;
}
} else {
u = strrchr(e, '/');
if (!u) {
if (saveu) {
saveu[0] = '/';
}
return;
}
}
u[0] = '\0';
u_len = strlen(u + 1);
e_len -= u_len + 1;
if (e_len < 0) {
if (saveu) {
saveu[0] = '/';
}
return;
}
} while (1);
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,926 | static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool compress) /* {{{ */
{
const char *oldname = NULL;
phar_archive_data *phar = *sphar;
char *oldpath = NULL;
char *basename = NULL, *basepath = NULL;
char *newname = NULL, *newpath = NULL;
zval ret, arg1;
zend_class_entry *ce;
char *error;
const char *pcr_error;
int ext_len = ext ? strlen(ext) : 0;
int oldname_len;
phar_archive_data *pphar = NULL;
php_stream_statbuf ssb;
if (!ext) {
if (phar->is_zip) {
if (phar->is_data) {
ext = "zip";
} else {
ext = "phar.zip";
}
} else if (phar->is_tar) {
switch (phar->flags) {
case PHAR_FILE_COMPRESSED_GZ:
if (phar->is_data) {
ext = "tar.gz";
} else {
ext = "phar.tar.gz";
}
break;
case PHAR_FILE_COMPRESSED_BZ2:
if (phar->is_data) {
ext = "tar.bz2";
} else {
ext = "phar.tar.bz2";
}
break;
default:
if (phar->is_data) {
ext = "tar";
} else {
ext = "phar.tar";
}
}
} else {
switch (phar->flags) {
case PHAR_FILE_COMPRESSED_GZ:
ext = "phar.gz";
break;
case PHAR_FILE_COMPRESSED_BZ2:
ext = "phar.bz2";
break;
default:
ext = "phar";
}
}
} else if (phar_path_check(&ext, &ext_len, &pcr_error) > pcr_is_ok) {
if (phar->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
}
return NULL;
}
if (ext[0] == '.') {
++ext;
}
oldpath = estrndup(phar->fname, phar->fname_len);
if ((oldname = zend_memrchr(phar->fname, '/', phar->fname_len))) {
++oldname;
} else {
oldname = phar->fname;
}
oldname_len = strlen(oldname);
basename = estrndup(oldname, oldname_len);
spprintf(&newname, 0, "%s.%s", strtok(basename, "."), ext);
efree(basename);
basepath = estrndup(oldpath, (strlen(oldpath) - oldname_len));
phar->fname_len = spprintf(&newpath, 0, "%s%s", basepath, newname);
phar->fname = newpath;
phar->ext = newpath + phar->fname_len - strlen(ext) - 1;
efree(basepath);
efree(newname);
if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, newpath, phar->fname_len))) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", phar->fname);
return NULL;
}
if (NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len))) {
if (pphar->fname_len == phar->fname_len && !memcmp(pphar->fname, phar->fname, phar->fname_len)) {
if (!zend_hash_num_elements(&phar->manifest)) {
pphar->is_tar = phar->is_tar;
pphar->is_zip = phar->is_zip;
pphar->is_data = phar->is_data;
pphar->flags = phar->flags;
pphar->fp = phar->fp;
phar->fp = NULL;
phar_destroy_phar_data(phar);
*sphar = NULL;
phar = pphar;
phar->refcount++;
newpath = oldpath;
goto its_ok;
}
}
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, a phar with that name already exists", phar->fname);
return NULL;
}
its_ok:
if (SUCCESS == php_stream_stat_path(newpath, &ssb)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" exists and must be unlinked prior to conversion", newpath);
efree(oldpath);
return NULL;
}
if (!phar->is_data) {
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 1, 1, 1)) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext);
return NULL;
}
if (phar->alias) {
if (phar->is_temporary_alias) {
phar->alias = NULL;
phar->alias_len = 0;
} else {
phar->alias = estrndup(newpath, strlen(newpath));
phar->alias_len = strlen(newpath);
phar->is_temporary_alias = 1;
zend_hash_str_update_ptr(&(PHAR_G(phar_alias_map)), newpath, phar->fname_len, phar);
}
}
} else {
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 0, 1, 1)) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
return NULL;
}
phar->alias = NULL;
phar->alias_len = 0;
}
if ((!pphar || phar == pphar) && NULL == zend_hash_str_update_ptr(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len, phar)) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars", phar->fname);
return NULL;
}
phar_flush(phar, 0, 0, 1, &error);
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
efree(oldpath);
return NULL;
}
efree(oldpath);
if (phar->is_data) {
ce = phar_ce_data;
} else {
ce = phar_ce_archive;
}
ZVAL_NULL(&ret);
if (SUCCESS != object_init_ex(&ret, ce)) {
zval_dtor(&ret);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname);
return NULL;
}
ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len);
zend_call_method_with_1_params(&ret, ce, &ce->constructor, "__construct", NULL, &arg1);
zval_ptr_dtor(&arg1);
return Z_OBJ(ret);
}
/* }}} */
| Exec Code | 0 | static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext, zend_bool compress) /* {{{ */
{
const char *oldname = NULL;
phar_archive_data *phar = *sphar;
char *oldpath = NULL;
char *basename = NULL, *basepath = NULL;
char *newname = NULL, *newpath = NULL;
zval ret, arg1;
zend_class_entry *ce;
char *error;
const char *pcr_error;
int ext_len = ext ? strlen(ext) : 0;
int oldname_len;
phar_archive_data *pphar = NULL;
php_stream_statbuf ssb;
if (!ext) {
if (phar->is_zip) {
if (phar->is_data) {
ext = "zip";
} else {
ext = "phar.zip";
}
} else if (phar->is_tar) {
switch (phar->flags) {
case PHAR_FILE_COMPRESSED_GZ:
if (phar->is_data) {
ext = "tar.gz";
} else {
ext = "phar.tar.gz";
}
break;
case PHAR_FILE_COMPRESSED_BZ2:
if (phar->is_data) {
ext = "tar.bz2";
} else {
ext = "phar.tar.bz2";
}
break;
default:
if (phar->is_data) {
ext = "tar";
} else {
ext = "phar.tar";
}
}
} else {
switch (phar->flags) {
case PHAR_FILE_COMPRESSED_GZ:
ext = "phar.gz";
break;
case PHAR_FILE_COMPRESSED_BZ2:
ext = "phar.bz2";
break;
default:
ext = "phar";
}
}
} else if (phar_path_check(&ext, &ext_len, &pcr_error) > pcr_is_ok) {
if (phar->is_data) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
} else {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar converted from \"%s\" has invalid extension %s", phar->fname, ext);
}
return NULL;
}
if (ext[0] == '.') {
++ext;
}
oldpath = estrndup(phar->fname, phar->fname_len);
if ((oldname = zend_memrchr(phar->fname, '/', phar->fname_len))) {
++oldname;
} else {
oldname = phar->fname;
}
oldname_len = strlen(oldname);
basename = estrndup(oldname, oldname_len);
spprintf(&newname, 0, "%s.%s", strtok(basename, "."), ext);
efree(basename);
basepath = estrndup(oldpath, (strlen(oldpath) - oldname_len));
phar->fname_len = spprintf(&newpath, 0, "%s%s", basepath, newname);
phar->fname = newpath;
phar->ext = newpath + phar->fname_len - strlen(ext) - 1;
efree(basepath);
efree(newname);
if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_str_find_ptr(&cached_phars, newpath, phar->fname_len))) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", phar->fname);
return NULL;
}
if (NULL != (pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len))) {
if (pphar->fname_len == phar->fname_len && !memcmp(pphar->fname, phar->fname, phar->fname_len)) {
if (!zend_hash_num_elements(&phar->manifest)) {
pphar->is_tar = phar->is_tar;
pphar->is_zip = phar->is_zip;
pphar->is_data = phar->is_data;
pphar->flags = phar->flags;
pphar->fp = phar->fp;
phar->fp = NULL;
phar_destroy_phar_data(phar);
*sphar = NULL;
phar = pphar;
phar->refcount++;
newpath = oldpath;
goto its_ok;
}
}
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, a phar with that name already exists", phar->fname);
return NULL;
}
its_ok:
if (SUCCESS == php_stream_stat_path(newpath, &ssb)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" exists and must be unlinked prior to conversion", newpath);
efree(oldpath);
return NULL;
}
if (!phar->is_data) {
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 1, 1, 1)) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext);
return NULL;
}
if (phar->alias) {
if (phar->is_temporary_alias) {
phar->alias = NULL;
phar->alias_len = 0;
} else {
phar->alias = estrndup(newpath, strlen(newpath));
phar->alias_len = strlen(newpath);
phar->is_temporary_alias = 1;
zend_hash_str_update_ptr(&(PHAR_G(phar_alias_map)), newpath, phar->fname_len, phar);
}
}
} else {
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 0, 1, 1)) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", phar->fname, ext);
return NULL;
}
phar->alias = NULL;
phar->alias_len = 0;
}
if ((!pphar || phar == pphar) && NULL == zend_hash_str_update_ptr(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len, phar)) {
efree(oldpath);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars", phar->fname);
return NULL;
}
phar_flush(phar, 0, 0, 1, &error);
if (error) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s", error);
efree(error);
efree(oldpath);
return NULL;
}
efree(oldpath);
if (phar->is_data) {
ce = phar_ce_data;
} else {
ce = phar_ce_archive;
}
ZVAL_NULL(&ret);
if (SUCCESS != object_init_ex(&ret, ce)) {
zval_dtor(&ret);
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname);
return NULL;
}
ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len);
zend_call_method_with_1_params(&ret, ce, &ce->constructor, "__construct", NULL, &arg1);
zval_ptr_dtor(&arg1);
return Z_OBJ(ret);
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,927 | static int phar_set_compression(zval *zv, void *argument) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
php_uint32 compress = *(php_uint32 *)argument;
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
entry->old_flags = entry->flags;
entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
entry->flags |= compress;
entry->is_modified = 1;
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
| Exec Code | 0 | static int phar_set_compression(zval *zv, void *argument) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
php_uint32 compress = *(php_uint32 *)argument;
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
entry->old_flags = entry->flags;
entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
entry->flags |= compress;
entry->is_modified = 1;
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,928 | static void phar_spl_foreign_dtor(spl_filesystem_object *object) /* {{{ */
{
phar_archive_data *phar = (phar_archive_data *) object->oth;
if (!phar->is_persistent) {
phar_archive_delref(phar);
}
object->oth = NULL;
}
/* }}} */
| Exec Code | 0 | static void phar_spl_foreign_dtor(spl_filesystem_object *object) /* {{{ */
{
phar_archive_data *phar = (phar_archive_data *) object->oth;
if (!phar->is_persistent) {
phar_archive_delref(phar);
}
object->oth = NULL;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,929 | static int phar_test_compression(zval *zv, void *argument) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
if (!PHAR_G(has_bz2)) {
if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
*(int *) argument = 0;
}
}
if (!PHAR_G(has_zlib)) {
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
*(int *) argument = 0;
}
}
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
| Exec Code | 0 | static int phar_test_compression(zval *zv, void *argument) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv);
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
if (!PHAR_G(has_bz2)) {
if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
*(int *) argument = 0;
}
}
if (!PHAR_G(has_zlib)) {
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
*(int *) argument = 0;
}
}
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,930 | static int pharobj_cancompress(HashTable *manifest) /* {{{ */
{
int test;
test = 1;
zend_hash_apply_with_argument(manifest, phar_test_compression, &test);
return test;
}
/* }}} */
| Exec Code | 0 | static int pharobj_cancompress(HashTable *manifest) /* {{{ */
{
int test;
test = 1;
zend_hash_apply_with_argument(manifest, phar_test_compression, &test);
return test;
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,931 | static void pharobj_set_compression(HashTable *manifest, php_uint32 compress) /* {{{ */
{
zend_hash_apply_with_argument(manifest, phar_set_compression, &compress);
}
/* }}} */
| Exec Code | 0 | static void pharobj_set_compression(HashTable *manifest, php_uint32 compress) /* {{{ */
{
zend_hash_apply_with_argument(manifest, phar_set_compression, &compress);
}
/* }}} */
| @@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount)
size_t path_len, actual_len;
phar_archive_data *pphar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) {
return;
}
@@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub)
zend_string *stub;
size_t index_len = 0, webindex_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) {
return;
}
@@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar)
char *fname, *alias = NULL, *error;
size_t fname_len, alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
return;
}
@@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename)
int ext_len, is_executable;
zend_bool executable = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) {
return;
}
@@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct)
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data);
if (is_data) {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
@@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive)
int zname_len, arch_len, entry_len;
phar_archive_data *phar;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) {
RETURN_FALSE;
}
@@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
RETURN_FALSE;
}
@@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) {
return;
}
@@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet)
zend_string *sfname;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet)
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
+ && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset)
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
}
@@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) {
return;
}
@@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) {
return;
}
@@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) {
return;
}
@@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo)
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
@@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct)
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1;
- if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
return;
} | CWE-20 | null | null |
8,932 | PHP_FUNCTION(snmpget)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GET, SNMP_VERSION_1);
}
| Exec Code | 0 | PHP_FUNCTION(snmpget)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GET, SNMP_VERSION_1);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,933 | PHP_FUNCTION(snmpgetnext)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GETNEXT, SNMP_VERSION_1);
}
| Exec Code | 0 | PHP_FUNCTION(snmpgetnext)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GETNEXT, SNMP_VERSION_1);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,934 | PHP_FUNCTION(snmprealwalk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, SNMP_VERSION_1);
}
| Exec Code | 0 | PHP_FUNCTION(snmprealwalk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, SNMP_VERSION_1);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,935 | PHP_FUNCTION(snmpset)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, SNMP_VERSION_1);
}
| Exec Code | 0 | PHP_FUNCTION(snmpset)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, SNMP_VERSION_1);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,936 | PHP_FUNCTION(snmp_set_quick_print)
{
zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &a1) == FAILURE) {
RETURN_FALSE;
}
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, (int)a1);
RETURN_TRUE;
}
| Exec Code | 0 | PHP_FUNCTION(snmp_set_quick_print)
{
zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &a1) == FAILURE) {
RETURN_FALSE;
}
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, (int)a1);
RETURN_TRUE;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,937 | PHP_FUNCTION(snmp_set_enum_print)
{
zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &a1) == FAILURE) {
RETURN_FALSE;
}
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);
RETURN_TRUE;
}
| Exec Code | 0 | PHP_FUNCTION(snmp_set_enum_print)
{
zend_long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &a1) == FAILURE) {
RETURN_FALSE;
}
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);
RETURN_TRUE;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,938 | PHP_FUNCTION(snmp2_get)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GET, SNMP_VERSION_2c);
}
| Exec Code | 0 | PHP_FUNCTION(snmp2_get)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_GET, SNMP_VERSION_2c);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,939 | PHP_FUNCTION(snmp2_real_walk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, SNMP_VERSION_2c);
}
| Exec Code | 0 | PHP_FUNCTION(snmp2_real_walk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, SNMP_VERSION_2c);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,940 | PHP_FUNCTION(snmp2_set)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, SNMP_VERSION_2c);
}
| Exec Code | 0 | PHP_FUNCTION(snmp2_set)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, SNMP_VERSION_2c);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,941 | PHP_FUNCTION(snmp_set_valueretrieval)
{
zend_long method;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
RETURN_FALSE;
}
if (method >= 0 && method <= (SNMP_VALUE_LIBRARY|SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT)) {
SNMP_G(valueretrieval) = method;
RETURN_TRUE;
} else {
php_error_docref(NULL, E_WARNING, "Unknown SNMP value retrieval method '%pd'", method);
RETURN_FALSE;
}
}
| Exec Code | 0 | PHP_FUNCTION(snmp_set_valueretrieval)
{
zend_long method;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
RETURN_FALSE;
}
if (method >= 0 && method <= (SNMP_VALUE_LIBRARY|SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT)) {
SNMP_G(valueretrieval) = method;
RETURN_TRUE;
} else {
php_error_docref(NULL, E_WARNING, "Unknown SNMP value retrieval method '%pd'", method);
RETURN_FALSE;
}
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,942 | PHP_FUNCTION(snmp_read_mib)
{
char *filename;
size_t filename_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
RETURN_FALSE;
}
if (!read_mib(filename)) {
char *error = strerror(errno);
php_error_docref(NULL, E_WARNING, "Error while reading MIB file '%s': %s", filename, error);
RETURN_FALSE;
}
RETURN_TRUE;
}
| Exec Code | 0 | PHP_FUNCTION(snmp_read_mib)
{
char *filename;
size_t filename_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) {
RETURN_FALSE;
}
if (!read_mib(filename)) {
char *error = strerror(errno);
php_error_docref(NULL, E_WARNING, "Error while reading MIB file '%s': %s", filename, error);
RETURN_FALSE;
}
RETURN_TRUE;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,943 | PHP_METHOD(snmp, __construct)
{
php_snmp_object *snmp_object;
zval *object = getThis();
char *a1, *a2;
size_t a1_len, a2_len;
zend_long timeout = SNMP_DEFAULT_TIMEOUT;
zend_long retries = SNMP_DEFAULT_RETRIES;
zend_long version = SNMP_DEFAULT_VERSION;
int argc = ZEND_NUM_ARGS();
snmp_object = Z_SNMP_P(object);
if (zend_parse_parameters_throw(argc, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) {
return;
}
switch (version) {
case SNMP_VERSION_1:
case SNMP_VERSION_2c:
case SNMP_VERSION_3:
break;
default:
zend_throw_exception(zend_ce_exception, "Unknown SNMP protocol version", 0);
return;
}
/* handle re-open of snmp session */
if (snmp_object->session) {
netsnmp_session_free(&(snmp_object->session));
}
if (netsnmp_session_init(&(snmp_object->session), version, a1, a2, timeout, retries)) {
return;
}
snmp_object->max_oids = 0;
snmp_object->valueretrieval = SNMP_G(valueretrieval);
snmp_object->enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
snmp_object->oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
snmp_object->quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
snmp_object->oid_increasing_check = TRUE;
snmp_object->exceptions_enabled = 0;
}
| Exec Code | 0 | PHP_METHOD(snmp, __construct)
{
php_snmp_object *snmp_object;
zval *object = getThis();
char *a1, *a2;
size_t a1_len, a2_len;
zend_long timeout = SNMP_DEFAULT_TIMEOUT;
zend_long retries = SNMP_DEFAULT_RETRIES;
zend_long version = SNMP_DEFAULT_VERSION;
int argc = ZEND_NUM_ARGS();
snmp_object = Z_SNMP_P(object);
if (zend_parse_parameters_throw(argc, "lss|ll", &version, &a1, &a1_len, &a2, &a2_len, &timeout, &retries) == FAILURE) {
return;
}
switch (version) {
case SNMP_VERSION_1:
case SNMP_VERSION_2c:
case SNMP_VERSION_3:
break;
default:
zend_throw_exception(zend_ce_exception, "Unknown SNMP protocol version", 0);
return;
}
/* handle re-open of snmp session */
if (snmp_object->session) {
netsnmp_session_free(&(snmp_object->session));
}
if (netsnmp_session_init(&(snmp_object->session), version, a1, a2, timeout, retries)) {
return;
}
snmp_object->max_oids = 0;
snmp_object->valueretrieval = SNMP_G(valueretrieval);
snmp_object->enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
snmp_object->oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
snmp_object->quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
snmp_object->oid_increasing_check = TRUE;
snmp_object->exceptions_enabled = 0;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,944 | PHP_METHOD(snmp, close)
{
php_snmp_object *snmp_object;
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
if (zend_parse_parameters_none() == FAILURE) {
RETURN_FALSE;
}
netsnmp_session_free(&(snmp_object->session));
RETURN_TRUE;
}
| Exec Code | 0 | PHP_METHOD(snmp, close)
{
php_snmp_object *snmp_object;
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
if (zend_parse_parameters_none() == FAILURE) {
RETURN_FALSE;
}
netsnmp_session_free(&(snmp_object->session));
RETURN_TRUE;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,945 | PHP_METHOD(snmp, walk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, (-1));
}
| Exec Code | 0 | PHP_METHOD(snmp, walk)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_WALK, (-1));
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,946 | PHP_METHOD(snmp, set)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1));
}
| Exec Code | 0 | PHP_METHOD(snmp, set)
{
php_snmp(INTERNAL_FUNCTION_PARAM_PASSTHRU, SNMP_CMD_SET, (-1));
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,947 | PHP_METHOD(snmp, setSecurity)
{
php_snmp_object *snmp_object;
zval *object = getThis();
char *a1 = "", *a2 = "", *a3 = "", *a4 = "", *a5 = "", *a6 = "", *a7 = "";
size_t a1_len = 0, a2_len = 0, a3_len = 0, a4_len = 0, a5_len = 0, a6_len = 0, a7_len = 0;
int argc = ZEND_NUM_ARGS();
snmp_object = Z_SNMP_P(object);
if (zend_parse_parameters(argc, "s|ssssss", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len) == FAILURE) {
RETURN_FALSE;
}
if (netsnmp_session_set_security(snmp_object->session, a1, a2, a3, a4, a5, a6, a7)) {
/* Warning message sent already, just bail out */
RETURN_FALSE;
}
RETURN_TRUE;
}
| Exec Code | 0 | PHP_METHOD(snmp, setSecurity)
{
php_snmp_object *snmp_object;
zval *object = getThis();
char *a1 = "", *a2 = "", *a3 = "", *a4 = "", *a5 = "", *a6 = "", *a7 = "";
size_t a1_len = 0, a2_len = 0, a3_len = 0, a4_len = 0, a5_len = 0, a6_len = 0, a7_len = 0;
int argc = ZEND_NUM_ARGS();
snmp_object = Z_SNMP_P(object);
if (zend_parse_parameters(argc, "s|ssssss", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len) == FAILURE) {
RETURN_FALSE;
}
if (netsnmp_session_set_security(snmp_object->session, a1, a2, a3, a4, a5, a6, a7)) {
/* Warning message sent already, just bail out */
RETURN_FALSE;
}
RETURN_TRUE;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,948 | PHP_METHOD(snmp, getErrno)
{
php_snmp_object *snmp_object;
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
RETVAL_LONG(snmp_object->snmp_errno);
return;
}
| Exec Code | 0 | PHP_METHOD(snmp, getErrno)
{
php_snmp_object *snmp_object;
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
RETVAL_LONG(snmp_object->snmp_errno);
return;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,949 | PHP_METHOD(snmp, getError)
{
php_snmp_object *snmp_object;
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
RETURN_STRING(snmp_object->snmp_errstr);
}
| Exec Code | 0 | PHP_METHOD(snmp, getError)
{
php_snmp_object *snmp_object;
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
RETURN_STRING(snmp_object->snmp_errstr);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,950 | PHP_MINIT_FUNCTION(snmp)
{
netsnmp_log_handler *logh;
zend_class_entry ce, cex;
le_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);
init_snmp("snmpapp");
#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE
/* Prevent update of the snmpapp.conf file */
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
#endif
/* Disable logging, use exit status'es and related variabled to detect errors */
shutdown_snmp_logging();
logh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);
if (logh) {
logh->pri_max = LOG_ERR;
}
memcpy(&php_snmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_snmp_object_handlers.read_property = php_snmp_read_property;
php_snmp_object_handlers.write_property = php_snmp_write_property;
php_snmp_object_handlers.has_property = php_snmp_has_property;
php_snmp_object_handlers.get_properties = php_snmp_get_properties;
/* Register SNMP Class */
INIT_CLASS_ENTRY(ce, "SNMP", php_snmp_class_methods);
ce.create_object = php_snmp_object_new;
php_snmp_object_handlers.offset = XtOffsetOf(php_snmp_object, zo);
php_snmp_object_handlers.clone_obj = NULL;
php_snmp_object_handlers.free_obj = php_snmp_object_free_storage;
php_snmp_ce = zend_register_internal_class(&ce);
/* Register SNMP Class properties */
zend_hash_init(&php_snmp_properties, 0, NULL, free_php_snmp_properties, 1);
PHP_SNMP_ADD_PROPERTIES(&php_snmp_properties, php_snmp_property_entries);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", NETSNMP_OID_OUTPUT_SUFFIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", NETSNMP_OID_OUTPUT_MODULE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", NETSNMP_OID_OUTPUT_FULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", NETSNMP_OID_OUTPUT_NUMERIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", NETSNMP_OID_OUTPUT_UCD, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", NETSNMP_OID_OUTPUT_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_BIT_STR", ASN_BIT_STR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", ASN_OCTET_STR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OPAQUE", ASN_OPAQUE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_NULL", ASN_NULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", ASN_OBJECT_ID, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", ASN_IPADDRESS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_COUNTER", ASN_GAUGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", ASN_UNSIGNED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", ASN_TIMETICKS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_UINTEGER", ASN_UINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_1", SNMP_VERSION_1);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2c", SNMP_VERSION_2c);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2C", SNMP_VERSION_2c);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_3", SNMP_VERSION_3);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", PHP_SNMP_ERRNO_NOERROR);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ANY", PHP_SNMP_ERRNO_ANY);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", PHP_SNMP_ERRNO_GENERIC);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_TIMEOUT", PHP_SNMP_ERRNO_TIMEOUT);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", PHP_SNMP_ERRNO_ERROR_IN_REPLY);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", PHP_SNMP_ERRNO_OID_NOT_INCREASING);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_PARSING_ERROR", PHP_SNMP_ERRNO_OID_PARSING_ERROR);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_MULTIPLE_SET_QUERIES", PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES);
/* Register SNMPException class */
INIT_CLASS_ENTRY(cex, "SNMPException", NULL);
#ifdef HAVE_SPL
php_snmp_exception_ce = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException);
#else
php_snmp_exception_ce = zend_register_internal_class_ex(&cex, zend_ce_exception);
#endif
return SUCCESS;
}
| Exec Code | 0 | PHP_MINIT_FUNCTION(snmp)
{
netsnmp_log_handler *logh;
zend_class_entry ce, cex;
le_snmp_session = zend_register_list_destructors_ex(php_snmp_session_destructor, NULL, PHP_SNMP_SESSION_RES_NAME, module_number);
init_snmp("snmpapp");
#ifdef NETSNMP_DS_LIB_DONT_PERSIST_STATE
/* Prevent update of the snmpapp.conf file */
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST_STATE, 1);
#endif
/* Disable logging, use exit status'es and related variabled to detect errors */
shutdown_snmp_logging();
logh = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, LOG_ERR);
if (logh) {
logh->pri_max = LOG_ERR;
}
memcpy(&php_snmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_snmp_object_handlers.read_property = php_snmp_read_property;
php_snmp_object_handlers.write_property = php_snmp_write_property;
php_snmp_object_handlers.has_property = php_snmp_has_property;
php_snmp_object_handlers.get_properties = php_snmp_get_properties;
/* Register SNMP Class */
INIT_CLASS_ENTRY(ce, "SNMP", php_snmp_class_methods);
ce.create_object = php_snmp_object_new;
php_snmp_object_handlers.offset = XtOffsetOf(php_snmp_object, zo);
php_snmp_object_handlers.clone_obj = NULL;
php_snmp_object_handlers.free_obj = php_snmp_object_free_storage;
php_snmp_ce = zend_register_internal_class(&ce);
/* Register SNMP Class properties */
zend_hash_init(&php_snmp_properties, 0, NULL, free_php_snmp_properties, 1);
PHP_SNMP_ADD_PROPERTIES(&php_snmp_properties, php_snmp_property_entries);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_SUFFIX", NETSNMP_OID_OUTPUT_SUFFIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_MODULE", NETSNMP_OID_OUTPUT_MODULE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_FULL", NETSNMP_OID_OUTPUT_FULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NUMERIC", NETSNMP_OID_OUTPUT_NUMERIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_UCD", NETSNMP_OID_OUTPUT_UCD, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OID_OUTPUT_NONE", NETSNMP_OID_OUTPUT_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_LIBRARY", SNMP_VALUE_LIBRARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_PLAIN", SNMP_VALUE_PLAIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_VALUE_OBJECT", SNMP_VALUE_OBJECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_BIT_STR", ASN_BIT_STR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OCTET_STR", ASN_OCTET_STR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OPAQUE", ASN_OPAQUE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_NULL", ASN_NULL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_OBJECT_ID", ASN_OBJECT_ID, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_IPADDRESS", ASN_IPADDRESS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_COUNTER", ASN_GAUGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_UNSIGNED", ASN_UNSIGNED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_TIMETICKS", ASN_TIMETICKS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_UINTEGER", ASN_UINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_INTEGER", ASN_INTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SNMP_COUNTER64", ASN_COUNTER64, CONST_CS | CONST_PERSISTENT);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_1", SNMP_VERSION_1);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2c", SNMP_VERSION_2c);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_2C", SNMP_VERSION_2c);
REGISTER_SNMP_CLASS_CONST_LONG("VERSION_3", SNMP_VERSION_3);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_NOERROR", PHP_SNMP_ERRNO_NOERROR);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ANY", PHP_SNMP_ERRNO_ANY);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_GENERIC", PHP_SNMP_ERRNO_GENERIC);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_TIMEOUT", PHP_SNMP_ERRNO_TIMEOUT);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_ERROR_IN_REPLY", PHP_SNMP_ERRNO_ERROR_IN_REPLY);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_NOT_INCREASING", PHP_SNMP_ERRNO_OID_NOT_INCREASING);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_OID_PARSING_ERROR", PHP_SNMP_ERRNO_OID_PARSING_ERROR);
REGISTER_SNMP_CLASS_CONST_LONG("ERRNO_MULTIPLE_SET_QUERIES", PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES);
/* Register SNMPException class */
INIT_CLASS_ENTRY(cex, "SNMPException", NULL);
#ifdef HAVE_SPL
php_snmp_exception_ce = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException);
#else
php_snmp_exception_ce = zend_register_internal_class_ex(&cex, zend_ce_exception);
#endif
return SUCCESS;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,951 | static void free_php_snmp_properties(zval *el) /* {{{ */
{
pefree(Z_PTR_P(el), 1);
}
/* }}} */
| Exec Code | 0 | static void free_php_snmp_properties(zval *el) /* {{{ */
{
pefree(Z_PTR_P(el), 1);
}
/* }}} */
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,952 | static int netsnmp_session_gen_auth_key(struct snmp_session *s, char *pass)
{
int snmp_errno;
s->securityAuthKeyLen = USM_AUTH_KU_LEN;
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
(u_char *) pass, strlen(pass),
s->securityAuthKey, &(s->securityAuthKeyLen)))) {
php_error_docref(NULL, E_WARNING, "Error generating a key for authentication pass phrase '%s': %s", pass, snmp_api_errstring(snmp_errno));
return (-1);
}
return (0);
}
| Exec Code | 0 | static int netsnmp_session_gen_auth_key(struct snmp_session *s, char *pass)
{
int snmp_errno;
s->securityAuthKeyLen = USM_AUTH_KU_LEN;
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
(u_char *) pass, strlen(pass),
s->securityAuthKey, &(s->securityAuthKeyLen)))) {
php_error_docref(NULL, E_WARNING, "Error generating a key for authentication pass phrase '%s': %s", pass, snmp_api_errstring(snmp_errno));
return (-1);
}
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,953 | static int netsnmp_session_gen_sec_key(struct snmp_session *s, char *pass)
{
int snmp_errno;
s->securityPrivKeyLen = USM_PRIV_KU_LEN;
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
(u_char *)pass, strlen(pass),
s->securityPrivKey, &(s->securityPrivKeyLen)))) {
php_error_docref(NULL, E_WARNING, "Error generating a key for privacy pass phrase '%s': %s", pass, snmp_api_errstring(snmp_errno));
return (-2);
}
return (0);
}
| Exec Code | 0 | static int netsnmp_session_gen_sec_key(struct snmp_session *s, char *pass)
{
int snmp_errno;
s->securityPrivKeyLen = USM_PRIV_KU_LEN;
if ((snmp_errno = generate_Ku(s->securityAuthProto, s->securityAuthProtoLen,
(u_char *)pass, strlen(pass),
s->securityPrivKey, &(s->securityPrivKeyLen)))) {
php_error_docref(NULL, E_WARNING, "Error generating a key for privacy pass phrase '%s': %s", pass, snmp_api_errstring(snmp_errno));
return (-2);
}
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,954 | static int netsnmp_session_init(php_snmp_session **session_p, int version, char *hostname, char *community, int timeout, int retries)
{
php_snmp_session *session;
char *pptr, *host_ptr;
int force_ipv6 = FALSE;
int n;
struct sockaddr **psal;
struct sockaddr **res;
*session_p = (php_snmp_session *)emalloc(sizeof(php_snmp_session));
session = *session_p;
if (session == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed allocating session");
return (-1);
}
memset(session, 0, sizeof(php_snmp_session));
snmp_sess_init(session);
session->version = version;
session->remote_port = SNMP_PORT;
session->peername = emalloc(MAX_NAME_LEN);
if (session->peername == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed while copying hostname");
return (-1);
}
/* we copy original hostname for further processing */
strlcpy(session->peername, hostname, MAX_NAME_LEN);
host_ptr = session->peername;
/* Reading the hostname and its optional non-default port number */
if (*host_ptr == '[') { /* IPv6 address */
force_ipv6 = TRUE;
host_ptr++;
if ((pptr = strchr(host_ptr, ']'))) {
if (pptr[1] == ':') {
session->remote_port = atoi(pptr + 2);
}
*pptr = '\0';
} else {
php_error_docref(NULL, E_WARNING, "malformed IPv6 address, closing square bracket missing");
return (-1);
}
} else { /* IPv4 address */
if ((pptr = strchr(host_ptr, ':'))) {
session->remote_port = atoi(pptr + 1);
*pptr = '\0';
}
}
/* since Net-SNMP library requires 'udp6:' prefix for all IPv6 addresses (in FQDN form too) we need to
perform possible name resolution before running any SNMP queries */
if ((n = php_network_getaddresses(host_ptr, SOCK_DGRAM, &psal, NULL)) == 0) { /* some resolver error */
/* warnings sent, bailing out */
return (-1);
}
/* we have everything we need in psal, flush peername and fill it properly */
*(session->peername) = '\0';
res = psal;
while (n-- > 0) {
pptr = session->peername;
#if HAVE_GETADDRINFO && HAVE_IPV6 && HAVE_INET_NTOP
if (force_ipv6 && (*res)->sa_family != AF_INET6) {
res++;
continue;
}
if ((*res)->sa_family == AF_INET6) {
strcpy(session->peername, "udp6:[");
pptr = session->peername + strlen(session->peername);
inet_ntop((*res)->sa_family, &(((struct sockaddr_in6*)(*res))->sin6_addr), pptr, MAX_NAME_LEN);
strcat(pptr, "]");
} else if ((*res)->sa_family == AF_INET) {
inet_ntop((*res)->sa_family, &(((struct sockaddr_in*)(*res))->sin_addr), pptr, MAX_NAME_LEN);
} else {
res++;
continue;
}
#else
if ((*res)->sa_family != AF_INET) {
res++;
continue;
}
strcat(pptr, inet_ntoa(((struct sockaddr_in*)(*res))->sin_addr));
#endif
break;
}
if (strlen(session->peername) == 0) {
php_error_docref(NULL, E_WARNING, "Unknown failure while resolving '%s'", hostname);
return (-1);
}
/* XXX FIXME
There should be check for non-empty session->peername!
*/
/* put back non-standard SNMP port */
if (session->remote_port != SNMP_PORT) {
pptr = session->peername + strlen(session->peername);
sprintf(pptr, ":%d", session->remote_port);
}
php_network_freeaddresses(psal);
if (version == SNMP_VERSION_3) {
/* Setting the security name. */
session->securityName = estrdup(community);
session->securityNameLen = strlen(session->securityName);
} else {
session->authenticator = NULL;
session->community = (u_char *)estrdup(community);
session->community_len = strlen(community);
}
session->retries = retries;
session->timeout = timeout;
return (0);
}
| Exec Code | 0 | static int netsnmp_session_init(php_snmp_session **session_p, int version, char *hostname, char *community, int timeout, int retries)
{
php_snmp_session *session;
char *pptr, *host_ptr;
int force_ipv6 = FALSE;
int n;
struct sockaddr **psal;
struct sockaddr **res;
*session_p = (php_snmp_session *)emalloc(sizeof(php_snmp_session));
session = *session_p;
if (session == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed allocating session");
return (-1);
}
memset(session, 0, sizeof(php_snmp_session));
snmp_sess_init(session);
session->version = version;
session->remote_port = SNMP_PORT;
session->peername = emalloc(MAX_NAME_LEN);
if (session->peername == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed while copying hostname");
return (-1);
}
/* we copy original hostname for further processing */
strlcpy(session->peername, hostname, MAX_NAME_LEN);
host_ptr = session->peername;
/* Reading the hostname and its optional non-default port number */
if (*host_ptr == '[') { /* IPv6 address */
force_ipv6 = TRUE;
host_ptr++;
if ((pptr = strchr(host_ptr, ']'))) {
if (pptr[1] == ':') {
session->remote_port = atoi(pptr + 2);
}
*pptr = '\0';
} else {
php_error_docref(NULL, E_WARNING, "malformed IPv6 address, closing square bracket missing");
return (-1);
}
} else { /* IPv4 address */
if ((pptr = strchr(host_ptr, ':'))) {
session->remote_port = atoi(pptr + 1);
*pptr = '\0';
}
}
/* since Net-SNMP library requires 'udp6:' prefix for all IPv6 addresses (in FQDN form too) we need to
perform possible name resolution before running any SNMP queries */
if ((n = php_network_getaddresses(host_ptr, SOCK_DGRAM, &psal, NULL)) == 0) { /* some resolver error */
/* warnings sent, bailing out */
return (-1);
}
/* we have everything we need in psal, flush peername and fill it properly */
*(session->peername) = '\0';
res = psal;
while (n-- > 0) {
pptr = session->peername;
#if HAVE_GETADDRINFO && HAVE_IPV6 && HAVE_INET_NTOP
if (force_ipv6 && (*res)->sa_family != AF_INET6) {
res++;
continue;
}
if ((*res)->sa_family == AF_INET6) {
strcpy(session->peername, "udp6:[");
pptr = session->peername + strlen(session->peername);
inet_ntop((*res)->sa_family, &(((struct sockaddr_in6*)(*res))->sin6_addr), pptr, MAX_NAME_LEN);
strcat(pptr, "]");
} else if ((*res)->sa_family == AF_INET) {
inet_ntop((*res)->sa_family, &(((struct sockaddr_in*)(*res))->sin_addr), pptr, MAX_NAME_LEN);
} else {
res++;
continue;
}
#else
if ((*res)->sa_family != AF_INET) {
res++;
continue;
}
strcat(pptr, inet_ntoa(((struct sockaddr_in*)(*res))->sin_addr));
#endif
break;
}
if (strlen(session->peername) == 0) {
php_error_docref(NULL, E_WARNING, "Unknown failure while resolving '%s'", hostname);
return (-1);
}
/* XXX FIXME
There should be check for non-empty session->peername!
*/
/* put back non-standard SNMP port */
if (session->remote_port != SNMP_PORT) {
pptr = session->peername + strlen(session->peername);
sprintf(pptr, ":%d", session->remote_port);
}
php_network_freeaddresses(psal);
if (version == SNMP_VERSION_3) {
/* Setting the security name. */
session->securityName = estrdup(community);
session->securityNameLen = strlen(session->securityName);
} else {
session->authenticator = NULL;
session->community = (u_char *)estrdup(community);
session->community_len = strlen(community);
}
session->retries = retries;
session->timeout = timeout;
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,955 | static int netsnmp_session_set_auth_protocol(struct snmp_session *s, char *prot)
{
if (!strcasecmp(prot, "MD5")) {
s->securityAuthProto = usmHMACMD5AuthProtocol;
s->securityAuthProtoLen = USM_AUTH_PROTO_MD5_LEN;
} else if (!strcasecmp(prot, "SHA")) {
s->securityAuthProto = usmHMACSHA1AuthProtocol;
s->securityAuthProtoLen = USM_AUTH_PROTO_SHA_LEN;
} else {
php_error_docref(NULL, E_WARNING, "Unknown authentication protocol '%s'", prot);
return (-1);
}
return (0);
}
| Exec Code | 0 | static int netsnmp_session_set_auth_protocol(struct snmp_session *s, char *prot)
{
if (!strcasecmp(prot, "MD5")) {
s->securityAuthProto = usmHMACMD5AuthProtocol;
s->securityAuthProtoLen = USM_AUTH_PROTO_MD5_LEN;
} else if (!strcasecmp(prot, "SHA")) {
s->securityAuthProto = usmHMACSHA1AuthProtocol;
s->securityAuthProtoLen = USM_AUTH_PROTO_SHA_LEN;
} else {
php_error_docref(NULL, E_WARNING, "Unknown authentication protocol '%s'", prot);
return (-1);
}
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,956 | static int netsnmp_session_set_contextEngineID(struct snmp_session *s, char * contextEngineID)
{
size_t ebuf_len = 32, eout_len = 0;
u_char *ebuf = (u_char *) emalloc(ebuf_len);
if (ebuf == NULL) {
php_error_docref(NULL, E_WARNING, "malloc failure setting contextEngineID");
return (-1);
}
if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, contextEngineID)) {
php_error_docref(NULL, E_WARNING, "Bad engine ID value '%s'", contextEngineID);
efree(ebuf);
return (-1);
}
if (s->contextEngineID) {
efree(s->contextEngineID);
}
s->contextEngineID = ebuf;
s->contextEngineIDLen = eout_len;
return (0);
}
| Exec Code | 0 | static int netsnmp_session_set_contextEngineID(struct snmp_session *s, char * contextEngineID)
{
size_t ebuf_len = 32, eout_len = 0;
u_char *ebuf = (u_char *) emalloc(ebuf_len);
if (ebuf == NULL) {
php_error_docref(NULL, E_WARNING, "malloc failure setting contextEngineID");
return (-1);
}
if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, contextEngineID)) {
php_error_docref(NULL, E_WARNING, "Bad engine ID value '%s'", contextEngineID);
efree(ebuf);
return (-1);
}
if (s->contextEngineID) {
efree(s->contextEngineID);
}
s->contextEngineID = ebuf;
s->contextEngineIDLen = eout_len;
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,957 | static int netsnmp_session_set_sec_protocol(struct snmp_session *s, char *prot)
{
if (!strcasecmp(prot, "DES")) {
s->securityPrivProto = usmDESPrivProtocol;
s->securityPrivProtoLen = USM_PRIV_PROTO_DES_LEN;
#ifdef HAVE_AES
} else if (!strcasecmp(prot, "AES128") || !strcasecmp(prot, "AES")) {
s->securityPrivProto = usmAESPrivProtocol;
s->securityPrivProtoLen = USM_PRIV_PROTO_AES_LEN;
#endif
} else {
php_error_docref(NULL, E_WARNING, "Unknown security protocol '%s'", prot);
return (-1);
}
return (0);
}
| Exec Code | 0 | static int netsnmp_session_set_sec_protocol(struct snmp_session *s, char *prot)
{
if (!strcasecmp(prot, "DES")) {
s->securityPrivProto = usmDESPrivProtocol;
s->securityPrivProtoLen = USM_PRIV_PROTO_DES_LEN;
#ifdef HAVE_AES
} else if (!strcasecmp(prot, "AES128") || !strcasecmp(prot, "AES")) {
s->securityPrivProto = usmAESPrivProtocol;
s->securityPrivProtoLen = USM_PRIV_PROTO_AES_LEN;
#endif
} else {
php_error_docref(NULL, E_WARNING, "Unknown security protocol '%s'", prot);
return (-1);
}
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,958 | static int netsnmp_session_set_security(struct snmp_session *session, char *sec_level, char *auth_protocol, char *auth_passphrase, char *priv_protocol, char *priv_passphrase, char *contextName, char *contextEngineID)
{
/* Setting the security level. */
if (netsnmp_session_set_sec_level(session, sec_level)) {
php_error_docref(NULL, E_WARNING, "Invalid security level '%s'", sec_level);
return (-1);
}
if (session->securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV || session->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
/* Setting the authentication protocol. */
if (netsnmp_session_set_auth_protocol(session, auth_protocol)) {
/* Warning message sent already, just bail out */
return (-1);
}
/* Setting the authentication passphrase. */
if (netsnmp_session_gen_auth_key(session, auth_passphrase)) {
/* Warning message sent already, just bail out */
return (-1);
}
if (session->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
/* Setting the security protocol. */
if (netsnmp_session_set_sec_protocol(session, priv_protocol)) {
/* Warning message sent already, just bail out */
return (-1);
}
/* Setting the security protocol passphrase. */
if (netsnmp_session_gen_sec_key(session, priv_passphrase)) {
/* Warning message sent already, just bail out */
return (-1);
}
}
}
/* Setting contextName if specified */
if (contextName) {
session->contextName = contextName;
session->contextNameLen = strlen(contextName);
}
/* Setting contextEngineIS if specified */
if (contextEngineID && strlen(contextEngineID) && netsnmp_session_set_contextEngineID(session, contextEngineID)) {
/* Warning message sent already, just bail out */
return (-1);
}
return (0);
}
| Exec Code | 0 | static int netsnmp_session_set_security(struct snmp_session *session, char *sec_level, char *auth_protocol, char *auth_passphrase, char *priv_protocol, char *priv_passphrase, char *contextName, char *contextEngineID)
{
/* Setting the security level. */
if (netsnmp_session_set_sec_level(session, sec_level)) {
php_error_docref(NULL, E_WARNING, "Invalid security level '%s'", sec_level);
return (-1);
}
if (session->securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV || session->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
/* Setting the authentication protocol. */
if (netsnmp_session_set_auth_protocol(session, auth_protocol)) {
/* Warning message sent already, just bail out */
return (-1);
}
/* Setting the authentication passphrase. */
if (netsnmp_session_gen_auth_key(session, auth_passphrase)) {
/* Warning message sent already, just bail out */
return (-1);
}
if (session->securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
/* Setting the security protocol. */
if (netsnmp_session_set_sec_protocol(session, priv_protocol)) {
/* Warning message sent already, just bail out */
return (-1);
}
/* Setting the security protocol passphrase. */
if (netsnmp_session_gen_sec_key(session, priv_passphrase)) {
/* Warning message sent already, just bail out */
return (-1);
}
}
}
/* Setting contextName if specified */
if (contextName) {
session->contextName = contextName;
session->contextNameLen = strlen(contextName);
}
/* Setting contextEngineIS if specified */
if (contextEngineID && strlen(contextEngineID) && netsnmp_session_set_contextEngineID(session, contextEngineID)) {
/* Warning message sent already, just bail out */
return (-1);
}
return (0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,959 | static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
{
zval *oid, *value, *type;
char *a1, *a2, *a3, *a4, *a5, *a6, *a7;
size_t a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len;
zend_bool use_orignames = 0, suffix_keys = 0;
zend_long timeout = SNMP_DEFAULT_TIMEOUT;
zend_long retries = SNMP_DEFAULT_RETRIES;
int argc = ZEND_NUM_ARGS();
struct objid_query objid_query;
php_snmp_session *session;
int session_less_mode = (getThis() == NULL);
php_snmp_object *snmp_object;
php_snmp_object glob_snmp_object;
objid_query.max_repetitions = -1;
objid_query.non_repeaters = 0;
objid_query.valueretrieval = SNMP_G(valueretrieval);
objid_query.oid_increasing_check = TRUE;
if (session_less_mode) {
if (version == SNMP_VERSION_3) {
if (st & SNMP_CMD_SET) {
if (zend_parse_parameters(argc, "ssssssszzz|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len, &oid, &type, &value, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
} else {
/* SNMP_CMD_GET
* SNMP_CMD_GETNEXT
* SNMP_CMD_WALK
*/
if (zend_parse_parameters(argc, "sssssssz|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len, &oid, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
}
} else {
if (st & SNMP_CMD_SET) {
if (zend_parse_parameters(argc, "sszzz|ll", &a1, &a1_len, &a2, &a2_len, &oid, &type, &value, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
} else {
/* SNMP_CMD_GET
* SNMP_CMD_GETNEXT
* SNMP_CMD_WALK
*/
if (zend_parse_parameters(argc, "ssz|ll", &a1, &a1_len, &a2, &a2_len, &oid, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
}
}
} else {
if (st & SNMP_CMD_SET) {
if (zend_parse_parameters(argc, "zzz", &oid, &type, &value) == FAILURE) {
RETURN_FALSE;
}
} else if (st & SNMP_CMD_WALK) {
if (zend_parse_parameters(argc, "z|bll", &oid, &suffix_keys, &(objid_query.max_repetitions), &(objid_query.non_repeaters)) == FAILURE) {
RETURN_FALSE;
}
if (suffix_keys) {
st |= SNMP_USE_SUFFIX_AS_KEYS;
}
} else if (st & SNMP_CMD_GET) {
if (zend_parse_parameters(argc, "z|b", &oid, &use_orignames) == FAILURE) {
RETURN_FALSE;
}
if (use_orignames) {
st |= SNMP_ORIGINAL_NAMES_AS_KEYS;
}
} else {
/* SNMP_CMD_GETNEXT
*/
if (zend_parse_parameters(argc, "z", &oid) == FAILURE) {
RETURN_FALSE;
}
}
}
if (!php_snmp_parse_oid(getThis(), st, &objid_query, oid, type, value)) {
RETURN_FALSE;
}
if (session_less_mode) {
if (netsnmp_session_init(&session, version, a1, a2, timeout, retries)) {
efree(objid_query.vars);
netsnmp_session_free(&session);
RETURN_FALSE;
}
if (version == SNMP_VERSION_3 && netsnmp_session_set_security(session, a3, a4, a5, a6, a7, NULL, NULL)) {
efree(objid_query.vars);
netsnmp_session_free(&session);
/* Warning message sent already, just bail out */
RETURN_FALSE;
}
} else {
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
session = snmp_object->session;
if (!session) {
php_error_docref(NULL, E_WARNING, "Invalid or uninitialized SNMP object");
efree(objid_query.vars);
RETURN_FALSE;
}
if (snmp_object->max_oids > 0) {
objid_query.step = snmp_object->max_oids;
if (objid_query.max_repetitions < 0) { /* unspecified in function call, use session-wise */
objid_query.max_repetitions = snmp_object->max_oids;
}
}
objid_query.oid_increasing_check = snmp_object->oid_increasing_check;
objid_query.valueretrieval = snmp_object->valueretrieval;
glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print);
glob_snmp_object.quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, snmp_object->quick_print);
glob_snmp_object.oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, snmp_object->oid_output_format);
}
if (objid_query.max_repetitions < 0) {
objid_query.max_repetitions = 20; /* provide correct default value */
}
php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, session, &objid_query);
efree(objid_query.vars);
if (session_less_mode) {
netsnmp_session_free(&session);
} else {
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, glob_snmp_object.enum_print);
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, glob_snmp_object.quick_print);
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, glob_snmp_object.oid_output_format);
}
}
| Exec Code | 0 | static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
{
zval *oid, *value, *type;
char *a1, *a2, *a3, *a4, *a5, *a6, *a7;
size_t a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len;
zend_bool use_orignames = 0, suffix_keys = 0;
zend_long timeout = SNMP_DEFAULT_TIMEOUT;
zend_long retries = SNMP_DEFAULT_RETRIES;
int argc = ZEND_NUM_ARGS();
struct objid_query objid_query;
php_snmp_session *session;
int session_less_mode = (getThis() == NULL);
php_snmp_object *snmp_object;
php_snmp_object glob_snmp_object;
objid_query.max_repetitions = -1;
objid_query.non_repeaters = 0;
objid_query.valueretrieval = SNMP_G(valueretrieval);
objid_query.oid_increasing_check = TRUE;
if (session_less_mode) {
if (version == SNMP_VERSION_3) {
if (st & SNMP_CMD_SET) {
if (zend_parse_parameters(argc, "ssssssszzz|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len, &oid, &type, &value, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
} else {
/* SNMP_CMD_GET
* SNMP_CMD_GETNEXT
* SNMP_CMD_WALK
*/
if (zend_parse_parameters(argc, "sssssssz|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len,
&a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len, &oid, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
}
} else {
if (st & SNMP_CMD_SET) {
if (zend_parse_parameters(argc, "sszzz|ll", &a1, &a1_len, &a2, &a2_len, &oid, &type, &value, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
} else {
/* SNMP_CMD_GET
* SNMP_CMD_GETNEXT
* SNMP_CMD_WALK
*/
if (zend_parse_parameters(argc, "ssz|ll", &a1, &a1_len, &a2, &a2_len, &oid, &timeout, &retries) == FAILURE) {
RETURN_FALSE;
}
}
}
} else {
if (st & SNMP_CMD_SET) {
if (zend_parse_parameters(argc, "zzz", &oid, &type, &value) == FAILURE) {
RETURN_FALSE;
}
} else if (st & SNMP_CMD_WALK) {
if (zend_parse_parameters(argc, "z|bll", &oid, &suffix_keys, &(objid_query.max_repetitions), &(objid_query.non_repeaters)) == FAILURE) {
RETURN_FALSE;
}
if (suffix_keys) {
st |= SNMP_USE_SUFFIX_AS_KEYS;
}
} else if (st & SNMP_CMD_GET) {
if (zend_parse_parameters(argc, "z|b", &oid, &use_orignames) == FAILURE) {
RETURN_FALSE;
}
if (use_orignames) {
st |= SNMP_ORIGINAL_NAMES_AS_KEYS;
}
} else {
/* SNMP_CMD_GETNEXT
*/
if (zend_parse_parameters(argc, "z", &oid) == FAILURE) {
RETURN_FALSE;
}
}
}
if (!php_snmp_parse_oid(getThis(), st, &objid_query, oid, type, value)) {
RETURN_FALSE;
}
if (session_less_mode) {
if (netsnmp_session_init(&session, version, a1, a2, timeout, retries)) {
efree(objid_query.vars);
netsnmp_session_free(&session);
RETURN_FALSE;
}
if (version == SNMP_VERSION_3 && netsnmp_session_set_security(session, a3, a4, a5, a6, a7, NULL, NULL)) {
efree(objid_query.vars);
netsnmp_session_free(&session);
/* Warning message sent already, just bail out */
RETURN_FALSE;
}
} else {
zval *object = getThis();
snmp_object = Z_SNMP_P(object);
session = snmp_object->session;
if (!session) {
php_error_docref(NULL, E_WARNING, "Invalid or uninitialized SNMP object");
efree(objid_query.vars);
RETURN_FALSE;
}
if (snmp_object->max_oids > 0) {
objid_query.step = snmp_object->max_oids;
if (objid_query.max_repetitions < 0) { /* unspecified in function call, use session-wise */
objid_query.max_repetitions = snmp_object->max_oids;
}
}
objid_query.oid_increasing_check = snmp_object->oid_increasing_check;
objid_query.valueretrieval = snmp_object->valueretrieval;
glob_snmp_object.enum_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM);
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, snmp_object->enum_print);
glob_snmp_object.quick_print = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT);
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, snmp_object->quick_print);
glob_snmp_object.oid_output_format = netsnmp_ds_get_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT);
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, snmp_object->oid_output_format);
}
if (objid_query.max_repetitions < 0) {
objid_query.max_repetitions = 20; /* provide correct default value */
}
php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, session, &objid_query);
efree(objid_query.vars);
if (session_less_mode) {
netsnmp_session_free(&session);
} else {
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, glob_snmp_object.enum_print);
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT, glob_snmp_object.quick_print);
netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, glob_snmp_object.oid_output_format);
}
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,960 | static HashTable *php_snmp_get_properties(zval *object)
{
php_snmp_object *obj;
php_snmp_prop_handler *hnd;
HashTable *props;
zval rv;
zend_string *key;
zend_ulong num_key;
obj = Z_SNMP_P(object);
props = zend_std_get_properties(object);
ZEND_HASH_FOREACH_KEY_PTR(&php_snmp_properties, num_key, key, hnd) {
if (!hnd->read_func || hnd->read_func(obj, &rv) != SUCCESS) {
ZVAL_NULL(&rv);
}
zend_hash_update(props, key, &rv);
} ZEND_HASH_FOREACH_END();
return obj->zo.properties;
}
| Exec Code | 0 | static HashTable *php_snmp_get_properties(zval *object)
{
php_snmp_object *obj;
php_snmp_prop_handler *hnd;
HashTable *props;
zval rv;
zend_string *key;
zend_ulong num_key;
obj = Z_SNMP_P(object);
props = zend_std_get_properties(object);
ZEND_HASH_FOREACH_KEY_PTR(&php_snmp_properties, num_key, key, hnd) {
if (!hnd->read_func || hnd->read_func(obj, &rv) != SUCCESS) {
ZVAL_NULL(&rv);
}
zend_hash_update(props, key, &rv);
} ZEND_HASH_FOREACH_END();
return obj->zo.properties;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,961 | static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval, int valueretrieval)
{
zval val;
char sbuf[512];
char *buf = &(sbuf[0]);
char *dbuf = (char *)NULL;
int buflen = sizeof(sbuf) - 1;
int val_len = vars->val_len;
/* use emalloc() for large values, use static array otherwize */
/* There is no way to know the size of buffer snprint_value() needs in order to print a value there.
* So we are forced to probe it
*/
while ((valueretrieval & SNMP_VALUE_PLAIN) == 0) {
*buf = '\0';
if (snprint_value(buf, buflen, vars->name, vars->name_length, vars) == -1) {
if (val_len > 512*1024) {
php_error_docref(NULL, E_WARNING, "snprint_value() asks for a buffer more than 512k, Net-SNMP bug?");
break;
}
/* buffer is not long enough to hold full output, double it */
val_len *= 2;
} else {
break;
}
if (buf == dbuf) {
dbuf = (char *)erealloc(dbuf, val_len + 1);
} else {
dbuf = (char *)emalloc(val_len + 1);
}
if (!dbuf) {
php_error_docref(NULL, E_WARNING, "emalloc() failed: %s, fallback to static buffer", strerror(errno));
buf = &(sbuf[0]);
buflen = sizeof(sbuf) - 1;
break;
}
buf = dbuf;
buflen = val_len;
}
if((valueretrieval & SNMP_VALUE_PLAIN) && val_len > buflen){
if ((dbuf = (char *)emalloc(val_len + 1))) {
buf = dbuf;
buflen = val_len;
} else {
php_error_docref(NULL, E_WARNING, "emalloc() failed: %s, fallback to static buffer", strerror(errno));
}
}
if (valueretrieval & SNMP_VALUE_PLAIN) {
*buf = 0;
switch (vars->type) {
case ASN_BIT_STR: /* 0x03, asn1.h */
ZVAL_STRINGL(&val, (char *)vars->val.bitstring, vars->val_len);
break;
case ASN_OCTET_STR: /* 0x04, asn1.h */
case ASN_OPAQUE: /* 0x44, snmp_impl.h */
ZVAL_STRINGL(&val, (char *)vars->val.string, vars->val_len);
break;
case ASN_NULL: /* 0x05, asn1.h */
ZVAL_NULL(&val);
break;
case ASN_OBJECT_ID: /* 0x06, asn1.h */
snprint_objid(buf, buflen, vars->val.objid, vars->val_len / sizeof(oid));
ZVAL_STRING(&val, buf);
break;
case ASN_IPADDRESS: /* 0x40, snmp_impl.h */
snprintf(buf, buflen, "%d.%d.%d.%d",
(vars->val.string)[0], (vars->val.string)[1],
(vars->val.string)[2], (vars->val.string)[3]);
buf[buflen]=0;
ZVAL_STRING(&val, buf);
break;
case ASN_COUNTER: /* 0x41, snmp_impl.h */
case ASN_GAUGE: /* 0x42, snmp_impl.h */
/* ASN_UNSIGNED is the same as ASN_GAUGE */
case ASN_TIMETICKS: /* 0x43, snmp_impl.h */
case ASN_UINTEGER: /* 0x47, snmp_impl.h */
snprintf(buf, buflen, "%lu", *vars->val.integer);
buf[buflen]=0;
ZVAL_STRING(&val, buf);
break;
case ASN_INTEGER: /* 0x02, asn1.h */
snprintf(buf, buflen, "%ld", *vars->val.integer);
buf[buflen]=0;
ZVAL_STRING(&val, buf);
break;
#if defined(NETSNMP_WITH_OPAQUE_SPECIAL_TYPES) || defined(OPAQUE_SPECIAL_TYPES)
case ASN_OPAQUE_FLOAT: /* 0x78, asn1.h */
snprintf(buf, buflen, "%f", *vars->val.floatVal);
ZVAL_STRING(&val, buf);
break;
case ASN_OPAQUE_DOUBLE: /* 0x79, asn1.h */
snprintf(buf, buflen, "%Lf", *vars->val.doubleVal);
ZVAL_STRING(&val, buf);
break;
case ASN_OPAQUE_I64: /* 0x80, asn1.h */
printI64(buf, vars->val.counter64);
ZVAL_STRING(&val, buf);
break;
case ASN_OPAQUE_U64: /* 0x81, asn1.h */
#endif
case ASN_COUNTER64: /* 0x46, snmp_impl.h */
printU64(buf, vars->val.counter64);
ZVAL_STRING(&val, buf);
break;
default:
ZVAL_STRING(&val, "Unknown value type");
php_error_docref(NULL, E_WARNING, "Unknown value type: %u", vars->type);
break;
}
} else /* use Net-SNMP value translation */ {
/* we have desired string in buffer, just use it */
ZVAL_STRING(&val, buf);
}
if (valueretrieval & SNMP_VALUE_OBJECT) {
object_init(snmpval);
add_property_long(snmpval, "type", vars->type);
add_property_zval(snmpval, "value", &val);
} else {
ZVAL_COPY(snmpval, &val);
}
zval_ptr_dtor(&val);
if (dbuf){ /* malloc was used to store value */
efree(dbuf);
}
}
| Exec Code | 0 | static void php_snmp_getvalue(struct variable_list *vars, zval *snmpval, int valueretrieval)
{
zval val;
char sbuf[512];
char *buf = &(sbuf[0]);
char *dbuf = (char *)NULL;
int buflen = sizeof(sbuf) - 1;
int val_len = vars->val_len;
/* use emalloc() for large values, use static array otherwize */
/* There is no way to know the size of buffer snprint_value() needs in order to print a value there.
* So we are forced to probe it
*/
while ((valueretrieval & SNMP_VALUE_PLAIN) == 0) {
*buf = '\0';
if (snprint_value(buf, buflen, vars->name, vars->name_length, vars) == -1) {
if (val_len > 512*1024) {
php_error_docref(NULL, E_WARNING, "snprint_value() asks for a buffer more than 512k, Net-SNMP bug?");
break;
}
/* buffer is not long enough to hold full output, double it */
val_len *= 2;
} else {
break;
}
if (buf == dbuf) {
dbuf = (char *)erealloc(dbuf, val_len + 1);
} else {
dbuf = (char *)emalloc(val_len + 1);
}
if (!dbuf) {
php_error_docref(NULL, E_WARNING, "emalloc() failed: %s, fallback to static buffer", strerror(errno));
buf = &(sbuf[0]);
buflen = sizeof(sbuf) - 1;
break;
}
buf = dbuf;
buflen = val_len;
}
if((valueretrieval & SNMP_VALUE_PLAIN) && val_len > buflen){
if ((dbuf = (char *)emalloc(val_len + 1))) {
buf = dbuf;
buflen = val_len;
} else {
php_error_docref(NULL, E_WARNING, "emalloc() failed: %s, fallback to static buffer", strerror(errno));
}
}
if (valueretrieval & SNMP_VALUE_PLAIN) {
*buf = 0;
switch (vars->type) {
case ASN_BIT_STR: /* 0x03, asn1.h */
ZVAL_STRINGL(&val, (char *)vars->val.bitstring, vars->val_len);
break;
case ASN_OCTET_STR: /* 0x04, asn1.h */
case ASN_OPAQUE: /* 0x44, snmp_impl.h */
ZVAL_STRINGL(&val, (char *)vars->val.string, vars->val_len);
break;
case ASN_NULL: /* 0x05, asn1.h */
ZVAL_NULL(&val);
break;
case ASN_OBJECT_ID: /* 0x06, asn1.h */
snprint_objid(buf, buflen, vars->val.objid, vars->val_len / sizeof(oid));
ZVAL_STRING(&val, buf);
break;
case ASN_IPADDRESS: /* 0x40, snmp_impl.h */
snprintf(buf, buflen, "%d.%d.%d.%d",
(vars->val.string)[0], (vars->val.string)[1],
(vars->val.string)[2], (vars->val.string)[3]);
buf[buflen]=0;
ZVAL_STRING(&val, buf);
break;
case ASN_COUNTER: /* 0x41, snmp_impl.h */
case ASN_GAUGE: /* 0x42, snmp_impl.h */
/* ASN_UNSIGNED is the same as ASN_GAUGE */
case ASN_TIMETICKS: /* 0x43, snmp_impl.h */
case ASN_UINTEGER: /* 0x47, snmp_impl.h */
snprintf(buf, buflen, "%lu", *vars->val.integer);
buf[buflen]=0;
ZVAL_STRING(&val, buf);
break;
case ASN_INTEGER: /* 0x02, asn1.h */
snprintf(buf, buflen, "%ld", *vars->val.integer);
buf[buflen]=0;
ZVAL_STRING(&val, buf);
break;
#if defined(NETSNMP_WITH_OPAQUE_SPECIAL_TYPES) || defined(OPAQUE_SPECIAL_TYPES)
case ASN_OPAQUE_FLOAT: /* 0x78, asn1.h */
snprintf(buf, buflen, "%f", *vars->val.floatVal);
ZVAL_STRING(&val, buf);
break;
case ASN_OPAQUE_DOUBLE: /* 0x79, asn1.h */
snprintf(buf, buflen, "%Lf", *vars->val.doubleVal);
ZVAL_STRING(&val, buf);
break;
case ASN_OPAQUE_I64: /* 0x80, asn1.h */
printI64(buf, vars->val.counter64);
ZVAL_STRING(&val, buf);
break;
case ASN_OPAQUE_U64: /* 0x81, asn1.h */
#endif
case ASN_COUNTER64: /* 0x46, snmp_impl.h */
printU64(buf, vars->val.counter64);
ZVAL_STRING(&val, buf);
break;
default:
ZVAL_STRING(&val, "Unknown value type");
php_error_docref(NULL, E_WARNING, "Unknown value type: %u", vars->type);
break;
}
} else /* use Net-SNMP value translation */ {
/* we have desired string in buffer, just use it */
ZVAL_STRING(&val, buf);
}
if (valueretrieval & SNMP_VALUE_OBJECT) {
object_init(snmpval);
add_property_long(snmpval, "type", vars->type);
add_property_zval(snmpval, "value", &val);
} else {
ZVAL_COPY(snmpval, &val);
}
zval_ptr_dtor(&val);
if (dbuf){ /* malloc was used to store value */
efree(dbuf);
}
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,962 | static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot)
{
zval rv;
php_snmp_prop_handler *hnd;
int ret = 0;
if ((hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member))) != NULL) {
switch (has_set_exists) {
case 2:
ret = 1;
break;
case 0: {
zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
if (value != &EG(uninitialized_zval)) {
ret = Z_TYPE_P(value) != IS_NULL? 1 : 0;
zval_ptr_dtor(value);
}
break;
}
default: {
zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
if (value != &EG(uninitialized_zval)) {
convert_to_boolean(value);
ret = Z_TYPE_P(value) == IS_TRUE? 1:0;
}
break;
}
}
} else {
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
ret = std_hnd->has_property(object, member, has_set_exists, cache_slot);
}
return ret;
}
| Exec Code | 0 | static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot)
{
zval rv;
php_snmp_prop_handler *hnd;
int ret = 0;
if ((hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member))) != NULL) {
switch (has_set_exists) {
case 2:
ret = 1;
break;
case 0: {
zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
if (value != &EG(uninitialized_zval)) {
ret = Z_TYPE_P(value) != IS_NULL? 1 : 0;
zval_ptr_dtor(value);
}
break;
}
default: {
zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
if (value != &EG(uninitialized_zval)) {
convert_to_boolean(value);
ret = Z_TYPE_P(value) == IS_TRUE? 1:0;
}
break;
}
}
} else {
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
ret = std_hnd->has_property(object, member, has_set_exists, cache_slot);
}
return ret;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,963 | static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
struct snmp_session *session,
struct objid_query *objid_query)
{
struct snmp_session *ss;
struct snmp_pdu *pdu=NULL, *response;
struct variable_list *vars;
oid root[MAX_NAME_LEN];
size_t rootlen = 0;
int status, count, found;
char buf[2048];
char buf2[2048];
int keepwalking=1;
char *err;
zval snmpval;
int snmp_errno;
/* we start with retval=FALSE. If any actual data is acquired, retval will be set to appropriate type */
RETVAL_FALSE;
/* reset errno and errstr */
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_NOERROR, "");
if (st & SNMP_CMD_WALK) { /* remember root OID */
memmove((char *)root, (char *)(objid_query->vars[0].name), (objid_query->vars[0].name_length) * sizeof(oid));
rootlen = objid_query->vars[0].name_length;
objid_query->offset = objid_query->count;
}
if ((ss = snmp_open(session)) == NULL) {
snmp_error(session, NULL, NULL, &err);
php_error_docref(NULL, E_WARNING, "Could not open snmp connection: %s", err);
free(err);
RETVAL_FALSE;
return;
}
if ((st & SNMP_CMD_SET) && objid_query->count > objid_query->step) {
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES, "Can not fit all OIDs for SET query into one packet, using multiple queries");
}
while (keepwalking) {
keepwalking = 0;
if (st & SNMP_CMD_WALK) {
if (session->version == SNMP_VERSION_1) {
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
} else {
pdu = snmp_pdu_create(SNMP_MSG_GETBULK);
pdu->non_repeaters = objid_query->non_repeaters;
pdu->max_repetitions = objid_query->max_repetitions;
}
snmp_add_null_var(pdu, objid_query->vars[0].name, objid_query->vars[0].name_length);
} else {
if (st & SNMP_CMD_GET) {
pdu = snmp_pdu_create(SNMP_MSG_GET);
} else if (st & SNMP_CMD_GETNEXT) {
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
} else if (st & SNMP_CMD_SET) {
pdu = snmp_pdu_create(SNMP_MSG_SET);
} else {
snmp_close(ss);
php_error_docref(NULL, E_ERROR, "Unknown SNMP command (internals)");
RETVAL_FALSE;
return;
}
for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){
if (st & SNMP_CMD_SET) {
if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) {
snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno));
snmp_free_pdu(pdu);
snmp_close(ss);
RETVAL_FALSE;
return;
}
} else {
snmp_add_null_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length);
}
}
if(pdu->variables == NULL){
snmp_free_pdu(pdu);
snmp_close(ss);
RETVAL_FALSE;
return;
}
}
retry:
status = snmp_synch_response(ss, pdu, &response);
if (status == STAT_SUCCESS) {
if (response->errstat == SNMP_ERR_NOERROR) {
if (st & SNMP_CMD_SET) {
if (objid_query->offset < objid_query->count) { /* we have unprocessed OIDs */
keepwalking = 1;
continue;
}
snmp_free_pdu(response);
snmp_close(ss);
RETVAL_TRUE;
return;
}
for (vars = response->variables; vars; vars = vars->next_variable) {
/* do not output errors as values */
if ( vars->type == SNMP_ENDOFMIBVIEW ||
vars->type == SNMP_NOSUCHOBJECT ||
vars->type == SNMP_NOSUCHINSTANCE ) {
if ((st & SNMP_CMD_WALK) && Z_TYPE_P(return_value) == IS_ARRAY) {
break;
}
snprint_objid(buf, sizeof(buf), vars->name, vars->name_length);
snprint_value(buf2, sizeof(buf2), vars->name, vars->name_length, vars);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at '%s': %s", buf, buf2);
continue;
}
if ((st & SNMP_CMD_WALK) &&
(vars->name_length < rootlen || memcmp(root, vars->name, rootlen * sizeof(oid)))) { /* not part of this subtree */
if (Z_TYPE_P(return_value) == IS_ARRAY) { /* some records are fetched already, shut down further lookup */
keepwalking = 0;
} else {
/* first fetched OID is out of subtree, fallback to GET query */
st |= SNMP_CMD_GET;
st ^= SNMP_CMD_WALK;
objid_query->offset = 0;
keepwalking = 1;
}
break;
}
ZVAL_NULL(&snmpval);
php_snmp_getvalue(vars, &snmpval, objid_query->valueretrieval);
if (objid_query->array_output) {
if (Z_TYPE_P(return_value) == IS_TRUE || Z_TYPE_P(return_value) == IS_FALSE) {
array_init(return_value);
}
if (st & SNMP_NUMERIC_KEYS) {
add_next_index_zval(return_value, &snmpval);
} else if (st & SNMP_ORIGINAL_NAMES_AS_KEYS && st & SNMP_CMD_GET) {
found = 0;
for (count = 0; count < objid_query->count; count++) {
if (objid_query->vars[count].name_length == vars->name_length && snmp_oid_compare(objid_query->vars[count].name, objid_query->vars[count].name_length, vars->name, vars->name_length) == 0) {
found = 1;
objid_query->vars[count].name_length = 0; /* mark this name as used */
break;
}
}
if (found) {
add_assoc_zval(return_value, objid_query->vars[count].oid, &snmpval);
} else {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
php_error_docref(NULL, E_WARNING, "Could not find original OID name for '%s'", buf2);
}
} else if (st & SNMP_USE_SUFFIX_AS_KEYS && st & SNMP_CMD_WALK) {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
if (rootlen <= vars->name_length && snmp_oid_compare(root, rootlen, vars->name, rootlen) == 0) {
buf2[0] = '\0';
count = rootlen;
while(count < vars->name_length){
sprintf(buf, "%lu.", vars->name[count]);
strcat(buf2, buf);
count++;
}
buf2[strlen(buf2) - 1] = '\0'; /* remove trailing '.' */
}
add_assoc_zval(return_value, buf2, &snmpval);
} else {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
add_assoc_zval(return_value, buf2, &snmpval);
}
} else {
ZVAL_COPY_VALUE(return_value, &snmpval);
break;
}
/* OID increase check */
if (st & SNMP_CMD_WALK) {
if (objid_query->oid_increasing_check == TRUE && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, vars->name_length) >= 0) {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2);
keepwalking = 0;
} else {
memmove((char *)(objid_query->vars[0].name), (char *)vars->name, vars->name_length * sizeof(oid));
objid_query->vars[0].name_length = vars->name_length;
keepwalking = 1;
}
}
}
if (objid_query->offset < objid_query->count) { /* we have unprocessed OIDs */
keepwalking = 1;
}
} else {
if (st & SNMP_CMD_WALK && response->errstat == SNMP_ERR_TOOBIG && objid_query->max_repetitions > 1) { /* Answer will not fit into single packet */
objid_query->max_repetitions /= 2;
snmp_free_pdu(response);
keepwalking = 1;
continue;
}
if (!(st & SNMP_CMD_WALK) || response->errstat != SNMP_ERR_NOSUCHNAME || Z_TYPE_P(return_value) == IS_TRUE || Z_TYPE_P(return_value) == IS_FALSE) {
for (count=1, vars = response->variables;
vars && count != response->errindex;
vars = vars->next_variable, count++);
if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT) && response->errstat == SNMP_ERR_TOOBIG && objid_query->step > 1) { /* Answer will not fit into single packet */
objid_query->offset = ((objid_query->offset > objid_query->step) ? (objid_query->offset - objid_query->step) : 0 );
objid_query->step /= 2;
snmp_free_pdu(response);
keepwalking = 1;
continue;
}
if (vars) {
snprint_objid(buf, sizeof(buf), vars->name, vars->name_length);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at '%s': %s", buf, snmp_errstring(response->errstat));
} else {
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at %u object_id: %s", response->errindex, snmp_errstring(response->errstat));
}
if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT)) { /* cut out bogus OID and retry */
if ((pdu = snmp_fix_pdu(response, ((st & SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT) )) != NULL) {
snmp_free_pdu(response);
goto retry;
}
}
snmp_free_pdu(response);
snmp_close(ss);
if (objid_query->array_output) {
zval_ptr_dtor(return_value);
}
RETVAL_FALSE;
return;
}
}
} else if (status == STAT_TIMEOUT) {
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_TIMEOUT, "No response from %s", session->peername);
if (objid_query->array_output) {
zval_ptr_dtor(return_value);
}
snmp_close(ss);
RETVAL_FALSE;
return;
} else { /* status == STAT_ERROR */
snmp_error(ss, NULL, NULL, &err);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_GENERIC, "Fatal error: %s", err);
free(err);
if (objid_query->array_output) {
zval_ptr_dtor(return_value);
}
snmp_close(ss);
RETVAL_FALSE;
return;
}
if (response) {
snmp_free_pdu(response);
}
} /* keepwalking */
snmp_close(ss);
}
| Exec Code | 0 | static void php_snmp_internal(INTERNAL_FUNCTION_PARAMETERS, int st,
struct snmp_session *session,
struct objid_query *objid_query)
{
struct snmp_session *ss;
struct snmp_pdu *pdu=NULL, *response;
struct variable_list *vars;
oid root[MAX_NAME_LEN];
size_t rootlen = 0;
int status, count, found;
char buf[2048];
char buf2[2048];
int keepwalking=1;
char *err;
zval snmpval;
int snmp_errno;
/* we start with retval=FALSE. If any actual data is acquired, retval will be set to appropriate type */
RETVAL_FALSE;
/* reset errno and errstr */
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_NOERROR, "");
if (st & SNMP_CMD_WALK) { /* remember root OID */
memmove((char *)root, (char *)(objid_query->vars[0].name), (objid_query->vars[0].name_length) * sizeof(oid));
rootlen = objid_query->vars[0].name_length;
objid_query->offset = objid_query->count;
}
if ((ss = snmp_open(session)) == NULL) {
snmp_error(session, NULL, NULL, &err);
php_error_docref(NULL, E_WARNING, "Could not open snmp connection: %s", err);
free(err);
RETVAL_FALSE;
return;
}
if ((st & SNMP_CMD_SET) && objid_query->count > objid_query->step) {
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES, "Can not fit all OIDs for SET query into one packet, using multiple queries");
}
while (keepwalking) {
keepwalking = 0;
if (st & SNMP_CMD_WALK) {
if (session->version == SNMP_VERSION_1) {
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
} else {
pdu = snmp_pdu_create(SNMP_MSG_GETBULK);
pdu->non_repeaters = objid_query->non_repeaters;
pdu->max_repetitions = objid_query->max_repetitions;
}
snmp_add_null_var(pdu, objid_query->vars[0].name, objid_query->vars[0].name_length);
} else {
if (st & SNMP_CMD_GET) {
pdu = snmp_pdu_create(SNMP_MSG_GET);
} else if (st & SNMP_CMD_GETNEXT) {
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
} else if (st & SNMP_CMD_SET) {
pdu = snmp_pdu_create(SNMP_MSG_SET);
} else {
snmp_close(ss);
php_error_docref(NULL, E_ERROR, "Unknown SNMP command (internals)");
RETVAL_FALSE;
return;
}
for (count = 0; objid_query->offset < objid_query->count && count < objid_query->step; objid_query->offset++, count++){
if (st & SNMP_CMD_SET) {
if ((snmp_errno = snmp_add_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value))) {
snprint_objid(buf, sizeof(buf), objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Could not add variable: OID='%s' type='%c' value='%s': %s", buf, objid_query->vars[objid_query->offset].type, objid_query->vars[objid_query->offset].value, snmp_api_errstring(snmp_errno));
snmp_free_pdu(pdu);
snmp_close(ss);
RETVAL_FALSE;
return;
}
} else {
snmp_add_null_var(pdu, objid_query->vars[objid_query->offset].name, objid_query->vars[objid_query->offset].name_length);
}
}
if(pdu->variables == NULL){
snmp_free_pdu(pdu);
snmp_close(ss);
RETVAL_FALSE;
return;
}
}
retry:
status = snmp_synch_response(ss, pdu, &response);
if (status == STAT_SUCCESS) {
if (response->errstat == SNMP_ERR_NOERROR) {
if (st & SNMP_CMD_SET) {
if (objid_query->offset < objid_query->count) { /* we have unprocessed OIDs */
keepwalking = 1;
continue;
}
snmp_free_pdu(response);
snmp_close(ss);
RETVAL_TRUE;
return;
}
for (vars = response->variables; vars; vars = vars->next_variable) {
/* do not output errors as values */
if ( vars->type == SNMP_ENDOFMIBVIEW ||
vars->type == SNMP_NOSUCHOBJECT ||
vars->type == SNMP_NOSUCHINSTANCE ) {
if ((st & SNMP_CMD_WALK) && Z_TYPE_P(return_value) == IS_ARRAY) {
break;
}
snprint_objid(buf, sizeof(buf), vars->name, vars->name_length);
snprint_value(buf2, sizeof(buf2), vars->name, vars->name_length, vars);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at '%s': %s", buf, buf2);
continue;
}
if ((st & SNMP_CMD_WALK) &&
(vars->name_length < rootlen || memcmp(root, vars->name, rootlen * sizeof(oid)))) { /* not part of this subtree */
if (Z_TYPE_P(return_value) == IS_ARRAY) { /* some records are fetched already, shut down further lookup */
keepwalking = 0;
} else {
/* first fetched OID is out of subtree, fallback to GET query */
st |= SNMP_CMD_GET;
st ^= SNMP_CMD_WALK;
objid_query->offset = 0;
keepwalking = 1;
}
break;
}
ZVAL_NULL(&snmpval);
php_snmp_getvalue(vars, &snmpval, objid_query->valueretrieval);
if (objid_query->array_output) {
if (Z_TYPE_P(return_value) == IS_TRUE || Z_TYPE_P(return_value) == IS_FALSE) {
array_init(return_value);
}
if (st & SNMP_NUMERIC_KEYS) {
add_next_index_zval(return_value, &snmpval);
} else if (st & SNMP_ORIGINAL_NAMES_AS_KEYS && st & SNMP_CMD_GET) {
found = 0;
for (count = 0; count < objid_query->count; count++) {
if (objid_query->vars[count].name_length == vars->name_length && snmp_oid_compare(objid_query->vars[count].name, objid_query->vars[count].name_length, vars->name, vars->name_length) == 0) {
found = 1;
objid_query->vars[count].name_length = 0; /* mark this name as used */
break;
}
}
if (found) {
add_assoc_zval(return_value, objid_query->vars[count].oid, &snmpval);
} else {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
php_error_docref(NULL, E_WARNING, "Could not find original OID name for '%s'", buf2);
}
} else if (st & SNMP_USE_SUFFIX_AS_KEYS && st & SNMP_CMD_WALK) {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
if (rootlen <= vars->name_length && snmp_oid_compare(root, rootlen, vars->name, rootlen) == 0) {
buf2[0] = '\0';
count = rootlen;
while(count < vars->name_length){
sprintf(buf, "%lu.", vars->name[count]);
strcat(buf2, buf);
count++;
}
buf2[strlen(buf2) - 1] = '\0'; /* remove trailing '.' */
}
add_assoc_zval(return_value, buf2, &snmpval);
} else {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
add_assoc_zval(return_value, buf2, &snmpval);
}
} else {
ZVAL_COPY_VALUE(return_value, &snmpval);
break;
}
/* OID increase check */
if (st & SNMP_CMD_WALK) {
if (objid_query->oid_increasing_check == TRUE && snmp_oid_compare(objid_query->vars[0].name, objid_query->vars[0].name_length, vars->name, vars->name_length) >= 0) {
snprint_objid(buf2, sizeof(buf2), vars->name, vars->name_length);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_OID_NOT_INCREASING, "Error: OID not increasing: %s", buf2);
keepwalking = 0;
} else {
memmove((char *)(objid_query->vars[0].name), (char *)vars->name, vars->name_length * sizeof(oid));
objid_query->vars[0].name_length = vars->name_length;
keepwalking = 1;
}
}
}
if (objid_query->offset < objid_query->count) { /* we have unprocessed OIDs */
keepwalking = 1;
}
} else {
if (st & SNMP_CMD_WALK && response->errstat == SNMP_ERR_TOOBIG && objid_query->max_repetitions > 1) { /* Answer will not fit into single packet */
objid_query->max_repetitions /= 2;
snmp_free_pdu(response);
keepwalking = 1;
continue;
}
if (!(st & SNMP_CMD_WALK) || response->errstat != SNMP_ERR_NOSUCHNAME || Z_TYPE_P(return_value) == IS_TRUE || Z_TYPE_P(return_value) == IS_FALSE) {
for (count=1, vars = response->variables;
vars && count != response->errindex;
vars = vars->next_variable, count++);
if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT) && response->errstat == SNMP_ERR_TOOBIG && objid_query->step > 1) { /* Answer will not fit into single packet */
objid_query->offset = ((objid_query->offset > objid_query->step) ? (objid_query->offset - objid_query->step) : 0 );
objid_query->step /= 2;
snmp_free_pdu(response);
keepwalking = 1;
continue;
}
if (vars) {
snprint_objid(buf, sizeof(buf), vars->name, vars->name_length);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at '%s': %s", buf, snmp_errstring(response->errstat));
} else {
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_ERROR_IN_REPLY, "Error in packet at %u object_id: %s", response->errindex, snmp_errstring(response->errstat));
}
if (st & (SNMP_CMD_GET | SNMP_CMD_GETNEXT)) { /* cut out bogus OID and retry */
if ((pdu = snmp_fix_pdu(response, ((st & SNMP_CMD_GET) ? SNMP_MSG_GET : SNMP_MSG_GETNEXT) )) != NULL) {
snmp_free_pdu(response);
goto retry;
}
}
snmp_free_pdu(response);
snmp_close(ss);
if (objid_query->array_output) {
zval_ptr_dtor(return_value);
}
RETVAL_FALSE;
return;
}
}
} else if (status == STAT_TIMEOUT) {
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_TIMEOUT, "No response from %s", session->peername);
if (objid_query->array_output) {
zval_ptr_dtor(return_value);
}
snmp_close(ss);
RETVAL_FALSE;
return;
} else { /* status == STAT_ERROR */
snmp_error(ss, NULL, NULL, &err);
php_snmp_error(getThis(), NULL, PHP_SNMP_ERRNO_GENERIC, "Fatal error: %s", err);
free(err);
if (objid_query->array_output) {
zval_ptr_dtor(return_value);
}
snmp_close(ss);
RETVAL_FALSE;
return;
}
if (response) {
snmp_free_pdu(response);
}
} /* keepwalking */
snmp_close(ss);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,964 | static void php_snmp_object_free_storage(zend_object *object) /* {{{ */
{
php_snmp_object *intern = php_snmp_fetch_object(object);
if (!intern) {
return;
}
netsnmp_session_free(&(intern->session));
zend_object_std_dtor(&intern->zo);
}
/* }}} */
| Exec Code | 0 | static void php_snmp_object_free_storage(zend_object *object) /* {{{ */
{
php_snmp_object *intern = php_snmp_fetch_object(object);
if (!intern) {
return;
}
netsnmp_session_free(&(intern->session));
zend_object_std_dtor(&intern->zo);
}
/* }}} */
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,965 | static zend_object *php_snmp_object_new(zend_class_entry *class_type) /* {{{ */
{
php_snmp_object *intern;
/* Allocate memory for it */
intern = ecalloc(1, sizeof(php_snmp_object) + zend_object_properties_size(class_type));
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
intern->zo.handlers = &php_snmp_object_handlers;
return &intern->zo;
}
/* }}} */
| Exec Code | 0 | static zend_object *php_snmp_object_new(zend_class_entry *class_type) /* {{{ */
{
php_snmp_object *intern;
/* Allocate memory for it */
intern = ecalloc(1, sizeof(php_snmp_object) + zend_object_properties_size(class_type));
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
intern->zo.handlers = &php_snmp_object_handlers;
return &intern->zo;
}
/* }}} */
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,966 | static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_query, zval *oid, zval *type, zval *value)
{
char *pptr;
uint32_t idx_type = 0, idx_value = 0;
zval *tmp_oid, *tmp_type, *tmp_value;
if (Z_TYPE_P(oid) != IS_ARRAY) {
convert_to_string_ex(oid);
}
if (st & SNMP_CMD_SET) {
if (Z_TYPE_P(type) != IS_ARRAY) {
convert_to_string_ex(type);
}
if (Z_TYPE_P(value) != IS_ARRAY) {
convert_to_string_ex(value);
}
}
objid_query->count = 0;
objid_query->array_output = ((st & SNMP_CMD_WALK) ? TRUE : FALSE);
if (Z_TYPE_P(oid) == IS_STRING) {
objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg));
if (objid_query->vars == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed while parsing oid: %s", strerror(errno));
efree(objid_query->vars);
return FALSE;
}
objid_query->vars[objid_query->count].oid = Z_STRVAL_P(oid);
if (st & SNMP_CMD_SET) {
if (Z_TYPE_P(type) == IS_STRING && Z_TYPE_P(value) == IS_STRING) {
if (Z_STRLEN_P(type) != 1) {
php_error_docref(NULL, E_WARNING, "Bogus type '%s', should be single char, got %u", Z_STRVAL_P(type), Z_STRLEN_P(type));
efree(objid_query->vars);
return FALSE;
}
pptr = Z_STRVAL_P(type);
objid_query->vars[objid_query->count].type = *pptr;
objid_query->vars[objid_query->count].value = Z_STRVAL_P(value);
} else {
php_error_docref(NULL, E_WARNING, "Single objid and multiple type or values are not supported");
efree(objid_query->vars);
return FALSE;
}
}
objid_query->count++;
} else if (Z_TYPE_P(oid) == IS_ARRAY) { /* we got objid array */
if (zend_hash_num_elements(Z_ARRVAL_P(oid)) == 0) {
php_error_docref(NULL, E_WARNING, "Got empty OID array");
return FALSE;
}
objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg) * zend_hash_num_elements(Z_ARRVAL_P(oid)));
if (objid_query->vars == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed while parsing oid array: %s", strerror(errno));
efree(objid_query->vars);
return FALSE;
}
objid_query->array_output = ( (st & SNMP_CMD_SET) ? FALSE : TRUE );
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(oid), tmp_oid) {
convert_to_string_ex(tmp_oid);
objid_query->vars[objid_query->count].oid = Z_STRVAL_P(tmp_oid);
if (st & SNMP_CMD_SET) {
if (Z_TYPE_P(type) == IS_STRING) {
pptr = Z_STRVAL_P(type);
objid_query->vars[objid_query->count].type = *pptr;
} else if (Z_TYPE_P(type) == IS_ARRAY) {
while (idx_type < Z_ARRVAL_P(type)->nNumUsed) {
tmp_type = &Z_ARRVAL_P(type)->arData[idx_type].val;
if (Z_TYPE_P(tmp_type) != IS_UNDEF) {
break;
}
idx_type++;
}
if (idx_type < Z_ARRVAL_P(type)->nNumUsed) {
convert_to_string_ex(tmp_type);
if (Z_STRLEN_P(tmp_type) != 1) {
php_error_docref(NULL, E_WARNING, "'%s': bogus type '%s', should be single char, got %u", Z_STRVAL_P(tmp_oid), Z_STRVAL_P(tmp_type), Z_STRLEN_P(tmp_type));
efree(objid_query->vars);
return FALSE;
}
pptr = Z_STRVAL_P(tmp_type);
objid_query->vars[objid_query->count].type = *pptr;
idx_type++;
} else {
php_error_docref(NULL, E_WARNING, "'%s': no type set", Z_STRVAL_P(tmp_oid));
efree(objid_query->vars);
return FALSE;
}
}
if (Z_TYPE_P(value) == IS_STRING) {
objid_query->vars[objid_query->count].value = Z_STRVAL_P(value);
} else if (Z_TYPE_P(value) == IS_ARRAY) {
while (idx_value < Z_ARRVAL_P(value)->nNumUsed) {
tmp_value = &Z_ARRVAL_P(value)->arData[idx_value].val;
if (Z_TYPE_P(tmp_value) != IS_UNDEF) {
break;
}
idx_value++;
}
if (idx_value < Z_ARRVAL_P(value)->nNumUsed) {
convert_to_string_ex(tmp_value);
objid_query->vars[objid_query->count].value = Z_STRVAL_P(tmp_value);
idx_value++;
} else {
php_error_docref(NULL, E_WARNING, "'%s': no value set", Z_STRVAL_P(tmp_oid));
efree(objid_query->vars);
return FALSE;
}
}
}
objid_query->count++;
} ZEND_HASH_FOREACH_END();
}
/* now parse all OIDs */
if (st & SNMP_CMD_WALK) {
if (objid_query->count > 1) {
php_snmp_error(object, NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Multi OID walks are not supported!");
efree(objid_query->vars);
return FALSE;
}
objid_query->vars[0].name_length = MAX_NAME_LEN;
if (strlen(objid_query->vars[0].oid)) { /* on a walk, an empty string means top of tree - no error */
if (!snmp_parse_oid(objid_query->vars[0].oid, objid_query->vars[0].name, &(objid_query->vars[0].name_length))) {
php_snmp_error(object, NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[0].oid);
efree(objid_query->vars);
return FALSE;
}
} else {
memmove((char *)objid_query->vars[0].name, (char *)objid_mib, sizeof(objid_mib));
objid_query->vars[0].name_length = sizeof(objid_mib) / sizeof(oid);
}
} else {
for (objid_query->offset = 0; objid_query->offset < objid_query->count; objid_query->offset++) {
objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN;
if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) {
php_snmp_error(object, NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid);
efree(objid_query->vars);
return FALSE;
}
}
}
objid_query->offset = 0;
objid_query->step = objid_query->count;
return (objid_query->count > 0);
}
| Exec Code | 0 | static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_query, zval *oid, zval *type, zval *value)
{
char *pptr;
uint32_t idx_type = 0, idx_value = 0;
zval *tmp_oid, *tmp_type, *tmp_value;
if (Z_TYPE_P(oid) != IS_ARRAY) {
convert_to_string_ex(oid);
}
if (st & SNMP_CMD_SET) {
if (Z_TYPE_P(type) != IS_ARRAY) {
convert_to_string_ex(type);
}
if (Z_TYPE_P(value) != IS_ARRAY) {
convert_to_string_ex(value);
}
}
objid_query->count = 0;
objid_query->array_output = ((st & SNMP_CMD_WALK) ? TRUE : FALSE);
if (Z_TYPE_P(oid) == IS_STRING) {
objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg));
if (objid_query->vars == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed while parsing oid: %s", strerror(errno));
efree(objid_query->vars);
return FALSE;
}
objid_query->vars[objid_query->count].oid = Z_STRVAL_P(oid);
if (st & SNMP_CMD_SET) {
if (Z_TYPE_P(type) == IS_STRING && Z_TYPE_P(value) == IS_STRING) {
if (Z_STRLEN_P(type) != 1) {
php_error_docref(NULL, E_WARNING, "Bogus type '%s', should be single char, got %u", Z_STRVAL_P(type), Z_STRLEN_P(type));
efree(objid_query->vars);
return FALSE;
}
pptr = Z_STRVAL_P(type);
objid_query->vars[objid_query->count].type = *pptr;
objid_query->vars[objid_query->count].value = Z_STRVAL_P(value);
} else {
php_error_docref(NULL, E_WARNING, "Single objid and multiple type or values are not supported");
efree(objid_query->vars);
return FALSE;
}
}
objid_query->count++;
} else if (Z_TYPE_P(oid) == IS_ARRAY) { /* we got objid array */
if (zend_hash_num_elements(Z_ARRVAL_P(oid)) == 0) {
php_error_docref(NULL, E_WARNING, "Got empty OID array");
return FALSE;
}
objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg) * zend_hash_num_elements(Z_ARRVAL_P(oid)));
if (objid_query->vars == NULL) {
php_error_docref(NULL, E_WARNING, "emalloc() failed while parsing oid array: %s", strerror(errno));
efree(objid_query->vars);
return FALSE;
}
objid_query->array_output = ( (st & SNMP_CMD_SET) ? FALSE : TRUE );
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(oid), tmp_oid) {
convert_to_string_ex(tmp_oid);
objid_query->vars[objid_query->count].oid = Z_STRVAL_P(tmp_oid);
if (st & SNMP_CMD_SET) {
if (Z_TYPE_P(type) == IS_STRING) {
pptr = Z_STRVAL_P(type);
objid_query->vars[objid_query->count].type = *pptr;
} else if (Z_TYPE_P(type) == IS_ARRAY) {
while (idx_type < Z_ARRVAL_P(type)->nNumUsed) {
tmp_type = &Z_ARRVAL_P(type)->arData[idx_type].val;
if (Z_TYPE_P(tmp_type) != IS_UNDEF) {
break;
}
idx_type++;
}
if (idx_type < Z_ARRVAL_P(type)->nNumUsed) {
convert_to_string_ex(tmp_type);
if (Z_STRLEN_P(tmp_type) != 1) {
php_error_docref(NULL, E_WARNING, "'%s': bogus type '%s', should be single char, got %u", Z_STRVAL_P(tmp_oid), Z_STRVAL_P(tmp_type), Z_STRLEN_P(tmp_type));
efree(objid_query->vars);
return FALSE;
}
pptr = Z_STRVAL_P(tmp_type);
objid_query->vars[objid_query->count].type = *pptr;
idx_type++;
} else {
php_error_docref(NULL, E_WARNING, "'%s': no type set", Z_STRVAL_P(tmp_oid));
efree(objid_query->vars);
return FALSE;
}
}
if (Z_TYPE_P(value) == IS_STRING) {
objid_query->vars[objid_query->count].value = Z_STRVAL_P(value);
} else if (Z_TYPE_P(value) == IS_ARRAY) {
while (idx_value < Z_ARRVAL_P(value)->nNumUsed) {
tmp_value = &Z_ARRVAL_P(value)->arData[idx_value].val;
if (Z_TYPE_P(tmp_value) != IS_UNDEF) {
break;
}
idx_value++;
}
if (idx_value < Z_ARRVAL_P(value)->nNumUsed) {
convert_to_string_ex(tmp_value);
objid_query->vars[objid_query->count].value = Z_STRVAL_P(tmp_value);
idx_value++;
} else {
php_error_docref(NULL, E_WARNING, "'%s': no value set", Z_STRVAL_P(tmp_oid));
efree(objid_query->vars);
return FALSE;
}
}
}
objid_query->count++;
} ZEND_HASH_FOREACH_END();
}
/* now parse all OIDs */
if (st & SNMP_CMD_WALK) {
if (objid_query->count > 1) {
php_snmp_error(object, NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Multi OID walks are not supported!");
efree(objid_query->vars);
return FALSE;
}
objid_query->vars[0].name_length = MAX_NAME_LEN;
if (strlen(objid_query->vars[0].oid)) { /* on a walk, an empty string means top of tree - no error */
if (!snmp_parse_oid(objid_query->vars[0].oid, objid_query->vars[0].name, &(objid_query->vars[0].name_length))) {
php_snmp_error(object, NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[0].oid);
efree(objid_query->vars);
return FALSE;
}
} else {
memmove((char *)objid_query->vars[0].name, (char *)objid_mib, sizeof(objid_mib));
objid_query->vars[0].name_length = sizeof(objid_mib) / sizeof(oid);
}
} else {
for (objid_query->offset = 0; objid_query->offset < objid_query->count; objid_query->offset++) {
objid_query->vars[objid_query->offset].name_length = MAX_OID_LEN;
if (!snmp_parse_oid(objid_query->vars[objid_query->offset].oid, objid_query->vars[objid_query->offset].name, &(objid_query->vars[objid_query->offset].name_length))) {
php_snmp_error(object, NULL, PHP_SNMP_ERRNO_OID_PARSING_ERROR, "Invalid object identifier: %s", objid_query->vars[objid_query->offset].oid);
efree(objid_query->vars);
return FALSE;
}
}
}
objid_query->offset = 0;
objid_query->step = objid_query->count;
return (objid_query->count > 0);
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,967 | static int php_snmp_read_info(php_snmp_object *snmp_object, zval *retval)
{
zval val;
array_init(retval);
if (snmp_object->session == NULL) {
return SUCCESS;
}
ZVAL_STRINGL(&val, snmp_object->session->peername, strlen(snmp_object->session->peername));
add_assoc_zval(retval, "hostname", &val);
ZVAL_LONG(&val, snmp_object->session->remote_port);
add_assoc_zval(retval, "port", &val);
ZVAL_LONG(&val, snmp_object->session->timeout);
add_assoc_zval(retval, "timeout", &val);
ZVAL_LONG(&val, snmp_object->session->retries);
add_assoc_zval(retval, "retries", &val);
return SUCCESS;
}
| Exec Code | 0 | static int php_snmp_read_info(php_snmp_object *snmp_object, zval *retval)
{
zval val;
array_init(retval);
if (snmp_object->session == NULL) {
return SUCCESS;
}
ZVAL_STRINGL(&val, snmp_object->session->peername, strlen(snmp_object->session->peername));
add_assoc_zval(retval, "hostname", &val);
ZVAL_LONG(&val, snmp_object->session->remote_port);
add_assoc_zval(retval, "port", &val);
ZVAL_LONG(&val, snmp_object->session->timeout);
add_assoc_zval(retval, "timeout", &val);
ZVAL_LONG(&val, snmp_object->session->retries);
add_assoc_zval(retval, "retries", &val);
return SUCCESS;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,968 | static int php_snmp_read_max_oids(php_snmp_object *snmp_object, zval *retval)
{
if (snmp_object->max_oids > 0) {
ZVAL_LONG(retval, snmp_object->max_oids);
} else {
ZVAL_NULL(retval);
}
return SUCCESS;
}
| Exec Code | 0 | static int php_snmp_read_max_oids(php_snmp_object *snmp_object, zval *retval)
{
if (snmp_object->max_oids > 0) {
ZVAL_LONG(retval, snmp_object->max_oids);
} else {
ZVAL_NULL(retval);
}
return SUCCESS;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,969 | zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
{
zval tmp_member;
zval *retval;
php_snmp_object *obj;
php_snmp_prop_handler *hnd;
int ret;
obj = Z_SNMP_P(object);
if (Z_TYPE_P(member) != IS_STRING) {
ZVAL_COPY(&tmp_member, member);
convert_to_string(&tmp_member);
member = &tmp_member;
}
hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member));
if (hnd && hnd->read_func) {
ret = hnd->read_func(obj, rv);
if (ret == SUCCESS) {
retval = rv;
} else {
retval = &EG(uninitialized_zval);
}
} else {
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
}
if (member == &tmp_member) {
zval_ptr_dtor(member);
}
return retval;
}
| Exec Code | 0 | zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
{
zval tmp_member;
zval *retval;
php_snmp_object *obj;
php_snmp_prop_handler *hnd;
int ret;
obj = Z_SNMP_P(object);
if (Z_TYPE_P(member) != IS_STRING) {
ZVAL_COPY(&tmp_member, member);
convert_to_string(&tmp_member);
member = &tmp_member;
}
hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member));
if (hnd && hnd->read_func) {
ret = hnd->read_func(obj, rv);
if (ret == SUCCESS) {
retval = rv;
} else {
retval = &EG(uninitialized_zval);
}
} else {
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
}
if (member == &tmp_member) {
zval_ptr_dtor(member);
}
return retval;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,970 | static int php_snmp_write_exceptions_enabled(php_snmp_object *snmp_object, zval *newval)
{
zval ztmp;
int ret = SUCCESS;
if (Z_TYPE_P(newval) != IS_LONG) {
ZVAL_COPY(&ztmp, newval);
convert_to_long(&ztmp);
newval = &ztmp;
}
snmp_object->exceptions_enabled = Z_LVAL_P(newval);
if (newval == &ztmp) {
zval_ptr_dtor(newval);
}
return ret;
}
| Exec Code | 0 | static int php_snmp_write_exceptions_enabled(php_snmp_object *snmp_object, zval *newval)
{
zval ztmp;
int ret = SUCCESS;
if (Z_TYPE_P(newval) != IS_LONG) {
ZVAL_COPY(&ztmp, newval);
convert_to_long(&ztmp);
newval = &ztmp;
}
snmp_object->exceptions_enabled = Z_LVAL_P(newval);
if (newval == &ztmp) {
zval_ptr_dtor(newval);
}
return ret;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,971 | static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *newval)
{
zval ztmp;
int ret = SUCCESS;
if (Z_TYPE_P(newval) != IS_LONG) {
ZVAL_COPY(&ztmp, newval);
convert_to_long(&ztmp);
newval = &ztmp;
}
switch(Z_LVAL_P(newval)) {
case NETSNMP_OID_OUTPUT_SUFFIX:
case NETSNMP_OID_OUTPUT_MODULE:
case NETSNMP_OID_OUTPUT_FULL:
case NETSNMP_OID_OUTPUT_NUMERIC:
case NETSNMP_OID_OUTPUT_UCD:
case NETSNMP_OID_OUTPUT_NONE:
snmp_object->oid_output_format = Z_LVAL_P(newval);
break;
default:
php_error_docref(NULL, E_WARNING, "Unknown SNMP output print format '%pd'", Z_LVAL_P(newval));
ret = FAILURE;
break;
}
if (newval == &ztmp) {
zval_ptr_dtor(newval);
}
return ret;
}
| Exec Code | 0 | static int php_snmp_write_oid_output_format(php_snmp_object *snmp_object, zval *newval)
{
zval ztmp;
int ret = SUCCESS;
if (Z_TYPE_P(newval) != IS_LONG) {
ZVAL_COPY(&ztmp, newval);
convert_to_long(&ztmp);
newval = &ztmp;
}
switch(Z_LVAL_P(newval)) {
case NETSNMP_OID_OUTPUT_SUFFIX:
case NETSNMP_OID_OUTPUT_MODULE:
case NETSNMP_OID_OUTPUT_FULL:
case NETSNMP_OID_OUTPUT_NUMERIC:
case NETSNMP_OID_OUTPUT_UCD:
case NETSNMP_OID_OUTPUT_NONE:
snmp_object->oid_output_format = Z_LVAL_P(newval);
break;
default:
php_error_docref(NULL, E_WARNING, "Unknown SNMP output print format '%pd'", Z_LVAL_P(newval));
ret = FAILURE;
break;
}
if (newval == &ztmp) {
zval_ptr_dtor(newval);
}
return ret;
}
| @@ -530,7 +530,7 @@ static void php_snmp_error(zval *object, const char *docref, int type, const cha
}
if (object && (snmp_object->exceptions_enabled & type)) {
- zend_throw_exception_ex(php_snmp_exception_ce, type, snmp_object->snmp_errstr);
+ zend_throw_exception_ex(php_snmp_exception_ce, type, "%s", snmp_object->snmp_errstr);
} else {
va_start(args, format);
php_verror(docref, "", E_WARNING, format, args); | CWE-20 | null | null |
8,972 | static void do_vapic_enable(void *data)
{
VAPICROMState *s = data;
X86CPU *cpu = X86_CPU(first_cpu);
static const uint8_t enabled = 1;
cpu_physical_memory_write(s->vapic_paddr + offsetof(VAPICState, enabled),
&enabled, sizeof(enabled));
apic_enable_vapic(cpu->apic_state, s->vapic_paddr);
s->state = VAPIC_ACTIVE;
}
| +Info | 0 | static void do_vapic_enable(void *data)
{
VAPICROMState *s = data;
X86CPU *cpu = X86_CPU(first_cpu);
static const uint8_t enabled = 1;
cpu_physical_memory_write(s->vapic_paddr + offsetof(VAPICState, enabled),
&enabled, sizeof(enabled));
apic_enable_vapic(cpu->apic_state, s->vapic_paddr);
s->state = VAPIC_ACTIVE;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,973 | static int evaluate_tpr_instruction(VAPICROMState *s, X86CPU *cpu,
target_ulong *pip, TPRAccess access)
{
CPUState *cs = CPU(cpu);
const TPRInstruction *instr;
target_ulong ip = *pip;
uint8_t opcode[2];
uint32_t real_tpr_addr;
int i;
if ((ip & 0xf0000000ULL) != 0x80000000ULL &&
(ip & 0xf0000000ULL) != 0xe0000000ULL) {
return -1;
}
/*
* Early Windows 2003 SMP initialization contains a
*
* mov imm32, r/m32
*
* instruction that is patched by TPR optimization. The problem is that
* RSP, used by the patched instruction, is zero, so the guest gets a
* double fault and dies.
*/
if (cpu->env.regs[R_ESP] == 0) {
return -1;
}
if (kvm_enabled() && !kvm_irqchip_in_kernel()) {
/*
* KVM without kernel-based TPR access reporting will pass an IP that
* points after the accessing instruction. So we need to look backward
* to find the reason.
*/
for (i = 0; i < ARRAY_SIZE(tpr_instr); i++) {
instr = &tpr_instr[i];
if (instr->access != access) {
continue;
}
if (cpu_memory_rw_debug(cs, ip - instr->length, opcode,
sizeof(opcode), 0) < 0) {
return -1;
}
if (opcode_matches(opcode, instr)) {
ip -= instr->length;
goto instruction_ok;
}
}
return -1;
} else {
if (cpu_memory_rw_debug(cs, ip, opcode, sizeof(opcode), 0) < 0) {
return -1;
}
for (i = 0; i < ARRAY_SIZE(tpr_instr); i++) {
instr = &tpr_instr[i];
if (opcode_matches(opcode, instr)) {
goto instruction_ok;
}
}
return -1;
}
instruction_ok:
/*
* Grab the virtual TPR address from the instruction
* and update the cached values.
*/
if (cpu_memory_rw_debug(cs, ip + instr->addr_offset,
(void *)&real_tpr_addr,
sizeof(real_tpr_addr), 0) < 0) {
return -1;
}
real_tpr_addr = le32_to_cpu(real_tpr_addr);
if ((real_tpr_addr & 0xfff) != 0x80) {
return -1;
}
s->real_tpr_addr = real_tpr_addr;
update_guest_rom_state(s);
*pip = ip;
return 0;
}
| +Info | 0 | static int evaluate_tpr_instruction(VAPICROMState *s, X86CPU *cpu,
target_ulong *pip, TPRAccess access)
{
CPUState *cs = CPU(cpu);
const TPRInstruction *instr;
target_ulong ip = *pip;
uint8_t opcode[2];
uint32_t real_tpr_addr;
int i;
if ((ip & 0xf0000000ULL) != 0x80000000ULL &&
(ip & 0xf0000000ULL) != 0xe0000000ULL) {
return -1;
}
/*
* Early Windows 2003 SMP initialization contains a
*
* mov imm32, r/m32
*
* instruction that is patched by TPR optimization. The problem is that
* RSP, used by the patched instruction, is zero, so the guest gets a
* double fault and dies.
*/
if (cpu->env.regs[R_ESP] == 0) {
return -1;
}
if (kvm_enabled() && !kvm_irqchip_in_kernel()) {
/*
* KVM without kernel-based TPR access reporting will pass an IP that
* points after the accessing instruction. So we need to look backward
* to find the reason.
*/
for (i = 0; i < ARRAY_SIZE(tpr_instr); i++) {
instr = &tpr_instr[i];
if (instr->access != access) {
continue;
}
if (cpu_memory_rw_debug(cs, ip - instr->length, opcode,
sizeof(opcode), 0) < 0) {
return -1;
}
if (opcode_matches(opcode, instr)) {
ip -= instr->length;
goto instruction_ok;
}
}
return -1;
} else {
if (cpu_memory_rw_debug(cs, ip, opcode, sizeof(opcode), 0) < 0) {
return -1;
}
for (i = 0; i < ARRAY_SIZE(tpr_instr); i++) {
instr = &tpr_instr[i];
if (opcode_matches(opcode, instr)) {
goto instruction_ok;
}
}
return -1;
}
instruction_ok:
/*
* Grab the virtual TPR address from the instruction
* and update the cached values.
*/
if (cpu_memory_rw_debug(cs, ip + instr->addr_offset,
(void *)&real_tpr_addr,
sizeof(real_tpr_addr), 0) < 0) {
return -1;
}
real_tpr_addr = le32_to_cpu(real_tpr_addr);
if ((real_tpr_addr & 0xfff) != 0x80) {
return -1;
}
s->real_tpr_addr = real_tpr_addr;
update_guest_rom_state(s);
*pip = ip;
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,974 | static uint8_t modrm_reg(uint8_t modrm)
{
return (modrm >> 3) & 7;
}
| +Info | 0 | static uint8_t modrm_reg(uint8_t modrm)
{
return (modrm >> 3) & 7;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,975 | static bool opcode_matches(uint8_t *opcode, const TPRInstruction *instr)
{
return opcode[0] == instr->opcode &&
(!(instr->flags & TPR_INSTR_ABS_MODRM) || is_abs_modrm(opcode[1])) &&
(!(instr->flags & TPR_INSTR_MATCH_MODRM_REG) ||
modrm_reg(opcode[1]) == instr->modrm_reg);
}
| +Info | 0 | static bool opcode_matches(uint8_t *opcode, const TPRInstruction *instr)
{
return opcode[0] == instr->opcode &&
(!(instr->flags & TPR_INSTR_ABS_MODRM) || is_abs_modrm(opcode[1])) &&
(!(instr->flags & TPR_INSTR_MATCH_MODRM_REG) ||
modrm_reg(opcode[1]) == instr->modrm_reg);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,976 | static void patch_byte(X86CPU *cpu, target_ulong addr, uint8_t byte)
{
cpu_memory_rw_debug(CPU(cpu), addr, &byte, 1, 1);
}
| +Info | 0 | static void patch_byte(X86CPU *cpu, target_ulong addr, uint8_t byte)
{
cpu_memory_rw_debug(CPU(cpu), addr, &byte, 1, 1);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,977 | static int patch_hypercalls(VAPICROMState *s)
{
hwaddr rom_paddr = s->rom_state_paddr & ROM_BLOCK_MASK;
static const uint8_t vmcall_pattern[] = { /* vmcall */
0xb8, 0x1, 0, 0, 0, 0xf, 0x1, 0xc1
};
static const uint8_t outl_pattern[] = { /* nop; outl %eax,0x7e */
0xb8, 0x1, 0, 0, 0, 0x90, 0xe7, 0x7e
};
uint8_t alternates[2];
const uint8_t *pattern;
const uint8_t *patch;
int patches = 0;
off_t pos;
uint8_t *rom;
rom = g_malloc(s->rom_size);
cpu_physical_memory_read(rom_paddr, rom, s->rom_size);
for (pos = 0; pos < s->rom_size - sizeof(vmcall_pattern); pos++) {
if (kvm_irqchip_in_kernel()) {
pattern = outl_pattern;
alternates[0] = outl_pattern[7];
alternates[1] = outl_pattern[7];
patch = &vmcall_pattern[5];
} else {
pattern = vmcall_pattern;
alternates[0] = vmcall_pattern[7];
alternates[1] = 0xd9; /* AMD's VMMCALL */
patch = &outl_pattern[5];
}
if (memcmp(rom + pos, pattern, 7) == 0 &&
(rom[pos + 7] == alternates[0] || rom[pos + 7] == alternates[1])) {
cpu_physical_memory_write(rom_paddr + pos + 5, patch, 3);
/*
* Don't flush the tb here. Under ordinary conditions, the patched
* calls are miles away from the current IP. Under malicious
* conditions, the guest could trick us to crash.
*/
}
}
g_free(rom);
if (patches != 0 && patches != 2) {
return -1;
}
return 0;
}
| +Info | 0 | static int patch_hypercalls(VAPICROMState *s)
{
hwaddr rom_paddr = s->rom_state_paddr & ROM_BLOCK_MASK;
static const uint8_t vmcall_pattern[] = { /* vmcall */
0xb8, 0x1, 0, 0, 0, 0xf, 0x1, 0xc1
};
static const uint8_t outl_pattern[] = { /* nop; outl %eax,0x7e */
0xb8, 0x1, 0, 0, 0, 0x90, 0xe7, 0x7e
};
uint8_t alternates[2];
const uint8_t *pattern;
const uint8_t *patch;
int patches = 0;
off_t pos;
uint8_t *rom;
rom = g_malloc(s->rom_size);
cpu_physical_memory_read(rom_paddr, rom, s->rom_size);
for (pos = 0; pos < s->rom_size - sizeof(vmcall_pattern); pos++) {
if (kvm_irqchip_in_kernel()) {
pattern = outl_pattern;
alternates[0] = outl_pattern[7];
alternates[1] = outl_pattern[7];
patch = &vmcall_pattern[5];
} else {
pattern = vmcall_pattern;
alternates[0] = vmcall_pattern[7];
alternates[1] = 0xd9; /* AMD's VMMCALL */
patch = &outl_pattern[5];
}
if (memcmp(rom + pos, pattern, 7) == 0 &&
(rom[pos + 7] == alternates[0] || rom[pos + 7] == alternates[1])) {
cpu_physical_memory_write(rom_paddr + pos + 5, patch, 3);
/*
* Don't flush the tb here. Under ordinary conditions, the patched
* calls are miles away from the current IP. Under malicious
* conditions, the guest could trick us to crash.
*/
}
}
g_free(rom);
if (patches != 0 && patches != 2) {
return -1;
}
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,978 | static void read_guest_rom_state(VAPICROMState *s)
{
cpu_physical_memory_read(s->rom_state_paddr, &s->rom_state,
sizeof(GuestROMState));
}
| +Info | 0 | static void read_guest_rom_state(VAPICROMState *s)
{
cpu_physical_memory_read(s->rom_state_paddr, &s->rom_state,
sizeof(GuestROMState));
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,979 | static void update_guest_rom_state(VAPICROMState *s)
{
read_guest_rom_state(s);
s->rom_state.real_tpr_addr = cpu_to_le32(s->real_tpr_addr);
s->rom_state.vcpu_shift = cpu_to_le32(VAPIC_CPU_SHIFT);
write_guest_rom_state(s);
}
| +Info | 0 | static void update_guest_rom_state(VAPICROMState *s)
{
read_guest_rom_state(s);
s->rom_state.real_tpr_addr = cpu_to_le32(s->real_tpr_addr);
s->rom_state.vcpu_shift = cpu_to_le32(VAPIC_CPU_SHIFT);
write_guest_rom_state(s);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,980 | static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong ip)
{
CPUState *cs = CPU(x86_env_get_cpu(env));
hwaddr paddr;
uint32_t rom_state_vaddr;
uint32_t pos, patch, offset;
/* nothing to do if already activated */
if (s->state == VAPIC_ACTIVE) {
return 0;
}
/* bail out if ROM init code was not executed (missing ROM?) */
if (s->state == VAPIC_INACTIVE) {
return -1;
}
/* find out virtual address of the ROM */
rom_state_vaddr = s->rom_state_paddr + (ip & 0xf0000000);
paddr = cpu_get_phys_page_debug(cs, rom_state_vaddr);
if (paddr == -1) {
return -1;
}
paddr += rom_state_vaddr & ~TARGET_PAGE_MASK;
if (paddr != s->rom_state_paddr) {
return -1;
}
read_guest_rom_state(s);
if (memcmp(s->rom_state.signature, "kvm aPiC", 8) != 0) {
return -1;
}
s->rom_state_vaddr = rom_state_vaddr;
/* fixup addresses in ROM if needed */
if (rom_state_vaddr == le32_to_cpu(s->rom_state.vaddr)) {
return 0;
}
for (pos = le32_to_cpu(s->rom_state.fixup_start);
pos < le32_to_cpu(s->rom_state.fixup_end);
pos += 4) {
cpu_physical_memory_read(paddr + pos - s->rom_state.vaddr,
&offset, sizeof(offset));
offset = le32_to_cpu(offset);
cpu_physical_memory_read(paddr + offset, &patch, sizeof(patch));
patch = le32_to_cpu(patch);
patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr);
patch = cpu_to_le32(patch);
cpu_physical_memory_write(paddr + offset, &patch, sizeof(patch));
}
read_guest_rom_state(s);
s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) -
le32_to_cpu(s->rom_state.vaddr);
return 0;
}
| +Info | 0 | static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong ip)
{
CPUState *cs = CPU(x86_env_get_cpu(env));
hwaddr paddr;
uint32_t rom_state_vaddr;
uint32_t pos, patch, offset;
/* nothing to do if already activated */
if (s->state == VAPIC_ACTIVE) {
return 0;
}
/* bail out if ROM init code was not executed (missing ROM?) */
if (s->state == VAPIC_INACTIVE) {
return -1;
}
/* find out virtual address of the ROM */
rom_state_vaddr = s->rom_state_paddr + (ip & 0xf0000000);
paddr = cpu_get_phys_page_debug(cs, rom_state_vaddr);
if (paddr == -1) {
return -1;
}
paddr += rom_state_vaddr & ~TARGET_PAGE_MASK;
if (paddr != s->rom_state_paddr) {
return -1;
}
read_guest_rom_state(s);
if (memcmp(s->rom_state.signature, "kvm aPiC", 8) != 0) {
return -1;
}
s->rom_state_vaddr = rom_state_vaddr;
/* fixup addresses in ROM if needed */
if (rom_state_vaddr == le32_to_cpu(s->rom_state.vaddr)) {
return 0;
}
for (pos = le32_to_cpu(s->rom_state.fixup_start);
pos < le32_to_cpu(s->rom_state.fixup_end);
pos += 4) {
cpu_physical_memory_read(paddr + pos - s->rom_state.vaddr,
&offset, sizeof(offset));
offset = le32_to_cpu(offset);
cpu_physical_memory_read(paddr + offset, &patch, sizeof(patch));
patch = le32_to_cpu(patch);
patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr);
patch = cpu_to_le32(patch);
cpu_physical_memory_write(paddr + offset, &patch, sizeof(patch));
}
read_guest_rom_state(s);
s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) -
le32_to_cpu(s->rom_state.vaddr);
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,981 | static void vapic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->reset = vapic_reset;
dc->vmsd = &vmstate_vapic;
dc->realize = vapic_realize;
}
| +Info | 0 | static void vapic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->reset = vapic_reset;
dc->vmsd = &vmstate_vapic;
dc->realize = vapic_realize;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,982 | static void vapic_do_enable_tpr_reporting(void *data)
{
VAPICEnableTPRReporting *info = data;
apic_enable_tpr_access_reporting(info->apic, info->enable);
}
| +Info | 0 | static void vapic_do_enable_tpr_reporting(void *data)
{
VAPICEnableTPRReporting *info = data;
apic_enable_tpr_access_reporting(info->apic, info->enable);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,983 | static int vapic_enable(VAPICROMState *s, X86CPU *cpu)
{
int cpu_number = get_kpcr_number(cpu);
hwaddr vapic_paddr;
static const uint8_t enabled = 1;
if (cpu_number < 0) {
return -1;
}
vapic_paddr = s->vapic_paddr +
(((hwaddr)cpu_number) << VAPIC_CPU_SHIFT);
cpu_physical_memory_write(vapic_paddr + offsetof(VAPICState, enabled),
&enabled, sizeof(enabled));
apic_enable_vapic(cpu->apic_state, vapic_paddr);
s->state = VAPIC_ACTIVE;
return 0;
}
| +Info | 0 | static int vapic_enable(VAPICROMState *s, X86CPU *cpu)
{
int cpu_number = get_kpcr_number(cpu);
hwaddr vapic_paddr;
static const uint8_t enabled = 1;
if (cpu_number < 0) {
return -1;
}
vapic_paddr = s->vapic_paddr +
(((hwaddr)cpu_number) << VAPIC_CPU_SHIFT);
cpu_physical_memory_write(vapic_paddr + offsetof(VAPICState, enabled),
&enabled, sizeof(enabled));
apic_enable_vapic(cpu->apic_state, vapic_paddr);
s->state = VAPIC_ACTIVE;
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,984 | static void vapic_enable_tpr_reporting(bool enable)
{
VAPICEnableTPRReporting info = {
.enable = enable,
};
CPUState *cs;
X86CPU *cpu;
CPU_FOREACH(cs) {
cpu = X86_CPU(cs);
info.apic = cpu->apic_state;
run_on_cpu(cs, vapic_do_enable_tpr_reporting, &info);
}
}
| +Info | 0 | static void vapic_enable_tpr_reporting(bool enable)
{
VAPICEnableTPRReporting info = {
.enable = enable,
};
CPUState *cs;
X86CPU *cpu;
CPU_FOREACH(cs) {
cpu = X86_CPU(cs);
info.apic = cpu->apic_state;
run_on_cpu(cs, vapic_do_enable_tpr_reporting, &info);
}
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,985 | static int vapic_map_rom_writable(VAPICROMState *s)
{
hwaddr rom_paddr = s->rom_state_paddr & ROM_BLOCK_MASK;
MemoryRegionSection section;
MemoryRegion *as;
size_t rom_size;
uint8_t *ram;
as = sysbus_address_space(&s->busdev);
if (s->rom_mapped_writable) {
memory_region_del_subregion(as, &s->rom);
object_unparent(OBJECT(&s->rom));
}
/* grab RAM memory region (region @rom_paddr may still be pc.rom) */
section = memory_region_find(as, 0, 1);
/* read ROM size from RAM region */
if (rom_paddr + 2 >= memory_region_size(section.mr)) {
return -1;
}
ram = memory_region_get_ram_ptr(section.mr);
rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
if (rom_size == 0) {
return -1;
}
s->rom_size = rom_size;
/* We need to round to avoid creating subpages
* from which we cannot run code. */
rom_size += rom_paddr & ~TARGET_PAGE_MASK;
rom_paddr &= TARGET_PAGE_MASK;
rom_size = TARGET_PAGE_ALIGN(rom_size);
memory_region_init_alias(&s->rom, OBJECT(s), "kvmvapic-rom", section.mr,
rom_paddr, rom_size);
memory_region_add_subregion_overlap(as, rom_paddr, &s->rom, 1000);
s->rom_mapped_writable = true;
memory_region_unref(section.mr);
return 0;
}
| +Info | 0 | static int vapic_map_rom_writable(VAPICROMState *s)
{
hwaddr rom_paddr = s->rom_state_paddr & ROM_BLOCK_MASK;
MemoryRegionSection section;
MemoryRegion *as;
size_t rom_size;
uint8_t *ram;
as = sysbus_address_space(&s->busdev);
if (s->rom_mapped_writable) {
memory_region_del_subregion(as, &s->rom);
object_unparent(OBJECT(&s->rom));
}
/* grab RAM memory region (region @rom_paddr may still be pc.rom) */
section = memory_region_find(as, 0, 1);
/* read ROM size from RAM region */
if (rom_paddr + 2 >= memory_region_size(section.mr)) {
return -1;
}
ram = memory_region_get_ram_ptr(section.mr);
rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE;
if (rom_size == 0) {
return -1;
}
s->rom_size = rom_size;
/* We need to round to avoid creating subpages
* from which we cannot run code. */
rom_size += rom_paddr & ~TARGET_PAGE_MASK;
rom_paddr &= TARGET_PAGE_MASK;
rom_size = TARGET_PAGE_ALIGN(rom_size);
memory_region_init_alias(&s->rom, OBJECT(s), "kvmvapic-rom", section.mr,
rom_paddr, rom_size);
memory_region_add_subregion_overlap(as, rom_paddr, &s->rom, 1000);
s->rom_mapped_writable = true;
memory_region_unref(section.mr);
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,986 | static int vapic_post_load(void *opaque, int version_id)
{
VAPICROMState *s = opaque;
/*
* The old implementation of qemu-kvm did not provide the state
* VAPIC_STANDBY. Reconstruct it.
*/
if (s->state == VAPIC_INACTIVE && s->rom_state_paddr != 0) {
s->state = VAPIC_STANDBY;
}
if (s->state != VAPIC_INACTIVE) {
if (vapic_prepare(s) < 0) {
return -1;
}
}
if (!s->vmsentry) {
s->vmsentry =
qemu_add_vm_change_state_handler(kvmvapic_vm_state_change, s);
}
return 0;
}
| +Info | 0 | static int vapic_post_load(void *opaque, int version_id)
{
VAPICROMState *s = opaque;
/*
* The old implementation of qemu-kvm did not provide the state
* VAPIC_STANDBY. Reconstruct it.
*/
if (s->state == VAPIC_INACTIVE && s->rom_state_paddr != 0) {
s->state = VAPIC_STANDBY;
}
if (s->state != VAPIC_INACTIVE) {
if (vapic_prepare(s) < 0) {
return -1;
}
}
if (!s->vmsentry) {
s->vmsentry =
qemu_add_vm_change_state_handler(kvmvapic_vm_state_change, s);
}
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,987 | static int vapic_prepare(VAPICROMState *s)
{
if (vapic_map_rom_writable(s) < 0) {
return -1;
}
if (patch_hypercalls(s) < 0) {
return -1;
}
vapic_enable_tpr_reporting(true);
return 0;
}
| +Info | 0 | static int vapic_prepare(VAPICROMState *s)
{
if (vapic_map_rom_writable(s) < 0) {
return -1;
}
if (patch_hypercalls(s) < 0) {
return -1;
}
vapic_enable_tpr_reporting(true);
return 0;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,988 | static uint64_t vapic_read(void *opaque, hwaddr addr, unsigned size)
{
return 0xffffffff;
}
| +Info | 0 | static uint64_t vapic_read(void *opaque, hwaddr addr, unsigned size)
{
return 0xffffffff;
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,989 | static void vapic_register(void)
{
type_register_static(&vapic_type);
}
| +Info | 0 | static void vapic_register(void)
{
type_register_static(&vapic_type);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,990 | void vapic_report_tpr_access(DeviceState *dev, CPUState *cs, target_ulong ip,
TPRAccess access)
{
VAPICROMState *s = VAPIC(dev);
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
cpu_synchronize_state(cs);
if (evaluate_tpr_instruction(s, cpu, &ip, access) < 0) {
if (s->state == VAPIC_ACTIVE) {
vapic_enable(s, cpu);
}
return;
}
if (update_rom_mapping(s, env, ip) < 0) {
return;
}
if (vapic_enable(s, cpu) < 0) {
return;
}
patch_instruction(s, cpu, ip);
}
| +Info | 0 | void vapic_report_tpr_access(DeviceState *dev, CPUState *cs, target_ulong ip,
TPRAccess access)
{
VAPICROMState *s = VAPIC(dev);
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
cpu_synchronize_state(cs);
if (evaluate_tpr_instruction(s, cpu, &ip, access) < 0) {
if (s->state == VAPIC_ACTIVE) {
vapic_enable(s, cpu);
}
return;
}
if (update_rom_mapping(s, env, ip) < 0) {
return;
}
if (vapic_enable(s, cpu) < 0) {
return;
}
patch_instruction(s, cpu, ip);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,991 | static void vapic_reset(DeviceState *dev)
{
VAPICROMState *s = VAPIC(dev);
s->state = VAPIC_INACTIVE;
s->rom_state_paddr = 0;
vapic_enable_tpr_reporting(false);
}
| +Info | 0 | static void vapic_reset(DeviceState *dev)
{
VAPICROMState *s = VAPIC(dev);
s->state = VAPIC_INACTIVE;
s->rom_state_paddr = 0;
vapic_enable_tpr_reporting(false);
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,992 | static void vapic_write(void *opaque, hwaddr addr, uint64_t data,
unsigned int size)
{
VAPICROMState *s = opaque;
X86CPU *cpu;
CPUX86State *env;
hwaddr rom_paddr;
if (!current_cpu) {
return;
}
cpu_synchronize_state(current_cpu);
cpu = X86_CPU(current_cpu);
env = &cpu->env;
/*
* The VAPIC supports two PIO-based hypercalls, both via port 0x7E.
* o 16-bit write access:
* Reports the option ROM initialization to the hypervisor. Written
* value is the offset of the state structure in the ROM.
* o 8-bit write access:
* Reactivates the VAPIC after a guest hibernation, i.e. after the
* option ROM content has been re-initialized by a guest power cycle.
* o 32-bit write access:
* Poll for pending IRQs, considering the current VAPIC state.
*/
switch (size) {
case 2:
if (s->state == VAPIC_INACTIVE) {
rom_paddr = (env->segs[R_CS].base + env->eip) & ROM_BLOCK_MASK;
s->rom_state_paddr = rom_paddr + data;
s->state = VAPIC_STANDBY;
}
if (vapic_prepare(s) < 0) {
s->state = VAPIC_INACTIVE;
s->rom_state_paddr = 0;
break;
}
break;
case 1:
if (kvm_enabled()) {
/*
* Disable triggering instruction in ROM by writing a NOP.
*
* We cannot do this in TCG mode as the reported IP is not
* accurate.
*/
pause_all_vcpus();
patch_byte(cpu, env->eip - 2, 0x66);
patch_byte(cpu, env->eip - 1, 0x90);
resume_all_vcpus();
}
if (s->state == VAPIC_ACTIVE) {
break;
}
if (update_rom_mapping(s, env, env->eip) < 0) {
break;
}
if (find_real_tpr_addr(s, env) < 0) {
break;
}
vapic_enable(s, cpu);
break;
default:
case 4:
if (!kvm_irqchip_in_kernel()) {
apic_poll_irq(cpu->apic_state);
}
break;
}
}
| +Info | 0 | static void vapic_write(void *opaque, hwaddr addr, uint64_t data,
unsigned int size)
{
VAPICROMState *s = opaque;
X86CPU *cpu;
CPUX86State *env;
hwaddr rom_paddr;
if (!current_cpu) {
return;
}
cpu_synchronize_state(current_cpu);
cpu = X86_CPU(current_cpu);
env = &cpu->env;
/*
* The VAPIC supports two PIO-based hypercalls, both via port 0x7E.
* o 16-bit write access:
* Reports the option ROM initialization to the hypervisor. Written
* value is the offset of the state structure in the ROM.
* o 8-bit write access:
* Reactivates the VAPIC after a guest hibernation, i.e. after the
* option ROM content has been re-initialized by a guest power cycle.
* o 32-bit write access:
* Poll for pending IRQs, considering the current VAPIC state.
*/
switch (size) {
case 2:
if (s->state == VAPIC_INACTIVE) {
rom_paddr = (env->segs[R_CS].base + env->eip) & ROM_BLOCK_MASK;
s->rom_state_paddr = rom_paddr + data;
s->state = VAPIC_STANDBY;
}
if (vapic_prepare(s) < 0) {
s->state = VAPIC_INACTIVE;
s->rom_state_paddr = 0;
break;
}
break;
case 1:
if (kvm_enabled()) {
/*
* Disable triggering instruction in ROM by writing a NOP.
*
* We cannot do this in TCG mode as the reported IP is not
* accurate.
*/
pause_all_vcpus();
patch_byte(cpu, env->eip - 2, 0x66);
patch_byte(cpu, env->eip - 1, 0x90);
resume_all_vcpus();
}
if (s->state == VAPIC_ACTIVE) {
break;
}
if (update_rom_mapping(s, env, env->eip) < 0) {
break;
}
if (find_real_tpr_addr(s, env) < 0) {
break;
}
vapic_enable(s, cpu);
break;
default:
case 4:
if (!kvm_irqchip_in_kernel()) {
apic_poll_irq(cpu->apic_state);
}
break;
}
}
| @@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
CPUX86State *env = &cpu->env;
VAPICHandlers *handlers;
uint8_t opcode[2];
- uint32_t imm32;
+ uint32_t imm32 = 0;
target_ulong current_pc = 0;
target_ulong current_cs_base = 0;
uint32_t current_flags = 0; | CWE-200 | null | null |
8,993 | _asn1_delete_not_used (asn1_node node)
{
asn1_node p, p2;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if (p->type & CONST_NOT_USED)
{
p2 = NULL;
if (p != node)
{
p2 = _asn1_find_left (p);
if (!p2)
p2 = _asn1_find_up (p);
}
asn1_delete_structure (&p);
p = p2;
}
if (!p)
break; /* reach node */
if (p->down)
{
p = p->down;
}
else
{
if (p == node)
p = NULL;
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_find_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
}
return ASN1_SUCCESS;
}
| DoS | 0 | _asn1_delete_not_used (asn1_node node)
{
asn1_node p, p2;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if (p->type & CONST_NOT_USED)
{
p2 = NULL;
if (p != node)
{
p2 = _asn1_find_left (p);
if (!p2)
p2 = _asn1_find_up (p);
}
asn1_delete_structure (&p);
p = p2;
}
if (!p)
break; /* reach node */
if (p->down)
{
p = p->down;
}
else
{
if (p == node)
p = NULL;
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_find_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
}
return ASN1_SUCCESS;
}
| @@ -753,7 +753,7 @@ _asn1_delete_not_used (asn1_node node)
static int
_asn1_extract_der_octet (asn1_node node, const unsigned char *der,
- int der_len, unsigned flags)
+ int der_len, unsigned flags, int *bytes)
{
int len2, len3;
int counter, counter_end;
@@ -799,15 +799,19 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
result =
_asn1_extract_der_octet (node, der + counter + len3,
- der_len, flags);
+ der_len, flags, &len2);
if (result != ASN1_SUCCESS)
return result;
- len2 = 0;
+
+ DECR_LEN(der_len, len2);
}
counter += len2 + len3 + 1;
}
+ if (bytes)
+ *bytes = counter;
+
return ASN1_SUCCESS;
cleanup:
@@ -889,7 +893,7 @@ get_octet_string (asn1_node node, const unsigned char *der, int der_len,
asn1_length_der (tot_len, temp, &len2);
_asn1_set_value (node, temp, len2);
- ret = _asn1_extract_der_octet (node, der, orig_der_len, flags);
+ ret = _asn1_extract_der_octet (node, der, orig_der_len, flags, NULL);
if (ret != ASN1_SUCCESS)
{
warn(); | CWE-399 | null | null |
8,994 | _asn1_error_description_tag_error (asn1_node node, char *ErrorDescription)
{
Estrcpy (ErrorDescription, ":: tag error near element '");
_asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
Estrcat (ErrorDescription, "'");
}
| DoS | 0 | _asn1_error_description_tag_error (asn1_node node, char *ErrorDescription)
{
Estrcpy (ErrorDescription, ":: tag error near element '");
_asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription),
ASN1_MAX_ERROR_DESCRIPTION_SIZE - 40);
Estrcat (ErrorDescription, "'");
}
| @@ -753,7 +753,7 @@ _asn1_delete_not_used (asn1_node node)
static int
_asn1_extract_der_octet (asn1_node node, const unsigned char *der,
- int der_len, unsigned flags)
+ int der_len, unsigned flags, int *bytes)
{
int len2, len3;
int counter, counter_end;
@@ -799,15 +799,19 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
result =
_asn1_extract_der_octet (node, der + counter + len3,
- der_len, flags);
+ der_len, flags, &len2);
if (result != ASN1_SUCCESS)
return result;
- len2 = 0;
+
+ DECR_LEN(der_len, len2);
}
counter += len2 + len3 + 1;
}
+ if (bytes)
+ *bytes = counter;
+
return ASN1_SUCCESS;
cleanup:
@@ -889,7 +893,7 @@ get_octet_string (asn1_node node, const unsigned char *der, int der_len,
asn1_length_der (tot_len, temp, &len2);
_asn1_set_value (node, temp, len2);
- ret = _asn1_extract_der_octet (node, der, orig_der_len, flags);
+ ret = _asn1_extract_der_octet (node, der, orig_der_len, flags, NULL);
if (ret != ASN1_SUCCESS)
{
warn(); | CWE-399 | null | null |
8,995 | _asn1_extract_tag_der (asn1_node node, const unsigned char *der, int der_len,
int *tag_len, int *inner_tag_len, unsigned flags)
{
asn1_node p;
int counter, len2, len3, is_tag_implicit;
int result;
unsigned long tag, tag_implicit = 0;
unsigned char class, class2, class_implicit = 0;
if (der_len <= 0)
return ASN1_GENERIC_ERROR;
counter = is_tag_implicit = 0;
if (node->type & CONST_TAG)
{
p = node->down;
while (p)
{
if (type_field (p->type) == ASN1_ETYPE_TAG)
{
if (p->type & CONST_APPLICATION)
class2 = ASN1_CLASS_APPLICATION;
else if (p->type & CONST_UNIVERSAL)
class2 = ASN1_CLASS_UNIVERSAL;
else if (p->type & CONST_PRIVATE)
class2 = ASN1_CLASS_PRIVATE;
else
class2 = ASN1_CLASS_CONTEXT_SPECIFIC;
if (p->type & CONST_EXPLICIT)
{
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
counter += len2;
if (flags & ASN1_DECODE_FLAG_STRICT_DER)
len3 =
asn1_get_length_der (der + counter, der_len,
&len2);
else
len3 =
asn1_get_length_ber (der + counter, der_len,
&len2);
if (len3 < 0)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
counter += len2;
if (!is_tag_implicit)
{
if ((class != (class2 | ASN1_CLASS_STRUCTURED)) ||
(tag != strtoul ((char *) p->value, NULL, 10)))
return ASN1_TAG_ERROR;
}
else
{ /* ASN1_TAG_IMPLICIT */
if ((class != class_implicit) || (tag != tag_implicit))
return ASN1_TAG_ERROR;
}
is_tag_implicit = 0;
}
else
{ /* ASN1_TAG_IMPLICIT */
if (!is_tag_implicit)
{
if ((type_field (node->type) == ASN1_ETYPE_SEQUENCE) ||
(type_field (node->type) == ASN1_ETYPE_SEQUENCE_OF)
|| (type_field (node->type) == ASN1_ETYPE_SET)
|| (type_field (node->type) == ASN1_ETYPE_SET_OF))
class2 |= ASN1_CLASS_STRUCTURED;
class_implicit = class2;
tag_implicit = strtoul ((char *) p->value, NULL, 10);
is_tag_implicit = 1;
}
}
}
p = p->right;
}
}
if (is_tag_implicit)
{
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
if ((class != class_implicit) || (tag != tag_implicit))
{
if (type_field (node->type) == ASN1_ETYPE_OCTET_STRING)
{
class_implicit |= ASN1_CLASS_STRUCTURED;
if ((class != class_implicit) || (tag != tag_implicit))
return ASN1_TAG_ERROR;
}
else
return ASN1_TAG_ERROR;
}
}
else
{
unsigned type = type_field (node->type);
if (type == ASN1_ETYPE_TAG)
{
*tag_len = 0;
if (inner_tag_len)
*inner_tag_len = 0;
return ASN1_SUCCESS;
}
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
switch (type)
{
case ASN1_ETYPE_NULL:
case ASN1_ETYPE_BOOLEAN:
case ASN1_ETYPE_INTEGER:
case ASN1_ETYPE_ENUMERATED:
case ASN1_ETYPE_OBJECT_ID:
case ASN1_ETYPE_GENERALSTRING:
case ASN1_ETYPE_NUMERIC_STRING:
case ASN1_ETYPE_IA5_STRING:
case ASN1_ETYPE_TELETEX_STRING:
case ASN1_ETYPE_PRINTABLE_STRING:
case ASN1_ETYPE_UNIVERSAL_STRING:
case ASN1_ETYPE_BMP_STRING:
case ASN1_ETYPE_UTF8_STRING:
case ASN1_ETYPE_VISIBLE_STRING:
case ASN1_ETYPE_BIT_STRING:
case ASN1_ETYPE_SEQUENCE:
case ASN1_ETYPE_SEQUENCE_OF:
case ASN1_ETYPE_SET:
case ASN1_ETYPE_SET_OF:
case ASN1_ETYPE_GENERALIZED_TIME:
case ASN1_ETYPE_UTC_TIME:
if ((class != _asn1_tags[type].class)
|| (tag != _asn1_tags[type].tag))
return ASN1_DER_ERROR;
break;
case ASN1_ETYPE_OCTET_STRING:
/* OCTET STRING is handled differently to allow
* BER encodings (structured class). */
if (((class != ASN1_CLASS_UNIVERSAL)
&& (class != (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED)))
|| (tag != ASN1_TAG_OCTET_STRING))
return ASN1_DER_ERROR;
break;
case ASN1_ETYPE_ANY:
counter -= len2;
break;
case ASN1_ETYPE_CHOICE:
counter -= len2;
break;
default:
return ASN1_DER_ERROR;
break;
}
}
counter += len2;
*tag_len = counter;
if (inner_tag_len)
*inner_tag_len = len2;
return ASN1_SUCCESS;
cleanup:
return result;
}
| DoS | 0 | _asn1_extract_tag_der (asn1_node node, const unsigned char *der, int der_len,
int *tag_len, int *inner_tag_len, unsigned flags)
{
asn1_node p;
int counter, len2, len3, is_tag_implicit;
int result;
unsigned long tag, tag_implicit = 0;
unsigned char class, class2, class_implicit = 0;
if (der_len <= 0)
return ASN1_GENERIC_ERROR;
counter = is_tag_implicit = 0;
if (node->type & CONST_TAG)
{
p = node->down;
while (p)
{
if (type_field (p->type) == ASN1_ETYPE_TAG)
{
if (p->type & CONST_APPLICATION)
class2 = ASN1_CLASS_APPLICATION;
else if (p->type & CONST_UNIVERSAL)
class2 = ASN1_CLASS_UNIVERSAL;
else if (p->type & CONST_PRIVATE)
class2 = ASN1_CLASS_PRIVATE;
else
class2 = ASN1_CLASS_CONTEXT_SPECIFIC;
if (p->type & CONST_EXPLICIT)
{
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
counter += len2;
if (flags & ASN1_DECODE_FLAG_STRICT_DER)
len3 =
asn1_get_length_der (der + counter, der_len,
&len2);
else
len3 =
asn1_get_length_ber (der + counter, der_len,
&len2);
if (len3 < 0)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
counter += len2;
if (!is_tag_implicit)
{
if ((class != (class2 | ASN1_CLASS_STRUCTURED)) ||
(tag != strtoul ((char *) p->value, NULL, 10)))
return ASN1_TAG_ERROR;
}
else
{ /* ASN1_TAG_IMPLICIT */
if ((class != class_implicit) || (tag != tag_implicit))
return ASN1_TAG_ERROR;
}
is_tag_implicit = 0;
}
else
{ /* ASN1_TAG_IMPLICIT */
if (!is_tag_implicit)
{
if ((type_field (node->type) == ASN1_ETYPE_SEQUENCE) ||
(type_field (node->type) == ASN1_ETYPE_SEQUENCE_OF)
|| (type_field (node->type) == ASN1_ETYPE_SET)
|| (type_field (node->type) == ASN1_ETYPE_SET_OF))
class2 |= ASN1_CLASS_STRUCTURED;
class_implicit = class2;
tag_implicit = strtoul ((char *) p->value, NULL, 10);
is_tag_implicit = 1;
}
}
}
p = p->right;
}
}
if (is_tag_implicit)
{
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
if ((class != class_implicit) || (tag != tag_implicit))
{
if (type_field (node->type) == ASN1_ETYPE_OCTET_STRING)
{
class_implicit |= ASN1_CLASS_STRUCTURED;
if ((class != class_implicit) || (tag != tag_implicit))
return ASN1_TAG_ERROR;
}
else
return ASN1_TAG_ERROR;
}
}
else
{
unsigned type = type_field (node->type);
if (type == ASN1_ETYPE_TAG)
{
*tag_len = 0;
if (inner_tag_len)
*inner_tag_len = 0;
return ASN1_SUCCESS;
}
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
switch (type)
{
case ASN1_ETYPE_NULL:
case ASN1_ETYPE_BOOLEAN:
case ASN1_ETYPE_INTEGER:
case ASN1_ETYPE_ENUMERATED:
case ASN1_ETYPE_OBJECT_ID:
case ASN1_ETYPE_GENERALSTRING:
case ASN1_ETYPE_NUMERIC_STRING:
case ASN1_ETYPE_IA5_STRING:
case ASN1_ETYPE_TELETEX_STRING:
case ASN1_ETYPE_PRINTABLE_STRING:
case ASN1_ETYPE_UNIVERSAL_STRING:
case ASN1_ETYPE_BMP_STRING:
case ASN1_ETYPE_UTF8_STRING:
case ASN1_ETYPE_VISIBLE_STRING:
case ASN1_ETYPE_BIT_STRING:
case ASN1_ETYPE_SEQUENCE:
case ASN1_ETYPE_SEQUENCE_OF:
case ASN1_ETYPE_SET:
case ASN1_ETYPE_SET_OF:
case ASN1_ETYPE_GENERALIZED_TIME:
case ASN1_ETYPE_UTC_TIME:
if ((class != _asn1_tags[type].class)
|| (tag != _asn1_tags[type].tag))
return ASN1_DER_ERROR;
break;
case ASN1_ETYPE_OCTET_STRING:
/* OCTET STRING is handled differently to allow
* BER encodings (structured class). */
if (((class != ASN1_CLASS_UNIVERSAL)
&& (class != (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED)))
|| (tag != ASN1_TAG_OCTET_STRING))
return ASN1_DER_ERROR;
break;
case ASN1_ETYPE_ANY:
counter -= len2;
break;
case ASN1_ETYPE_CHOICE:
counter -= len2;
break;
default:
return ASN1_DER_ERROR;
break;
}
}
counter += len2;
*tag_len = counter;
if (inner_tag_len)
*inner_tag_len = len2;
return ASN1_SUCCESS;
cleanup:
return result;
}
| @@ -767,10 +767,17 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
if (len2 == -1)
- counter_end = der_len - 2;
+ {
+ if (der_len < 2)
+ return ASN1_DER_ERROR;
+ counter_end = der_len - 2;
+ }
else
counter_end = der_len;
+ if (counter_end < counter)
+ return ASN1_DER_ERROR;
+
while (counter < counter_end)
{
DECR_LEN(der_len, 1); | CWE-399 | null | null |
8,996 | _asn1_get_indefinite_length_string (const unsigned char *der,
int der_len, int *len)
{
int len2, len3, counter, indefinite;
int result;
unsigned long tag;
unsigned char class;
counter = indefinite = 0;
while (1)
{
if (HAVE_TWO(der_len) && (der[counter] == 0) && (der[counter + 1] == 0))
{
counter += 2;
DECR_LEN(der_len, 2);
indefinite--;
if (indefinite <= 0)
break;
else
continue;
}
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
counter += len2;
len2 = asn1_get_length_der (der + counter, der_len, &len3);
if (len2 < -1)
return ASN1_DER_ERROR;
if (len2 == -1)
{
indefinite++;
counter += 1;
DECR_LEN(der_len, 1);
}
else
{
counter += len2 + len3;
DECR_LEN(der_len, len2+len3);
}
}
*len = counter;
return ASN1_SUCCESS;
cleanup:
return result;
}
| DoS | 0 | _asn1_get_indefinite_length_string (const unsigned char *der,
int der_len, int *len)
{
int len2, len3, counter, indefinite;
int result;
unsigned long tag;
unsigned char class;
counter = indefinite = 0;
while (1)
{
if (HAVE_TWO(der_len) && (der[counter] == 0) && (der[counter + 1] == 0))
{
counter += 2;
DECR_LEN(der_len, 2);
indefinite--;
if (indefinite <= 0)
break;
else
continue;
}
if (asn1_get_tag_der
(der + counter, der_len, &class, &len2,
&tag) != ASN1_SUCCESS)
return ASN1_DER_ERROR;
DECR_LEN(der_len, len2);
counter += len2;
len2 = asn1_get_length_der (der + counter, der_len, &len3);
if (len2 < -1)
return ASN1_DER_ERROR;
if (len2 == -1)
{
indefinite++;
counter += 1;
DECR_LEN(der_len, 1);
}
else
{
counter += len2 + len3;
DECR_LEN(der_len, len2+len3);
}
}
*len = counter;
return ASN1_SUCCESS;
cleanup:
return result;
}
| @@ -767,10 +767,17 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
if (len2 == -1)
- counter_end = der_len - 2;
+ {
+ if (der_len < 2)
+ return ASN1_DER_ERROR;
+ counter_end = der_len - 2;
+ }
else
counter_end = der_len;
+ if (counter_end < counter)
+ return ASN1_DER_ERROR;
+
while (counter < counter_end)
{
DECR_LEN(der_len, 1); | CWE-399 | null | null |
8,997 | _asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size, unsigned flags)
{
int len_len, str_len;
unsigned i;
unsigned sign_count = 0;
unsigned dot_count = 0;
const unsigned char *p;
if (der_len <= 0 || str == NULL)
return ASN1_DER_ERROR;
str_len = asn1_get_length_der (der, der_len, &len_len);
if (str_len <= 0 || str_size < str_len)
return ASN1_DER_ERROR;
/* perform some sanity checks on the data */
if (str_len < 8)
{
warn();
return ASN1_DER_ERROR;
}
if (flags & ASN1_DECODE_FLAG_STRICT_DER)
{
p = &der[len_len];
for (i=0;i<(unsigned)(str_len-1);i++)
{
if (isdigit(p[i]) == 0)
{
if (type == ASN1_ETYPE_GENERALIZED_TIME)
{
/* tolerate lax encodings */
if (p[i] == '.' && dot_count == 0)
{
dot_count++;
continue;
}
/* This is not really valid DER, but there are
* structures using that */
if (!(flags & ASN1_DECODE_FLAG_STRICT_DER) &&
(p[i] == '+' || p[i] == '-') && sign_count == 0)
{
sign_count++;
continue;
}
}
warn();
return ASN1_DER_ERROR;
}
}
if (sign_count == 0 && p[str_len-1] != 'Z')
{
warn();
return ASN1_DER_ERROR;
}
}
memcpy (str, der + len_len, str_len);
str[str_len] = 0;
*ret_len = str_len + len_len;
return ASN1_SUCCESS;
}
| DoS | 0 | _asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size, unsigned flags)
{
int len_len, str_len;
unsigned i;
unsigned sign_count = 0;
unsigned dot_count = 0;
const unsigned char *p;
if (der_len <= 0 || str == NULL)
return ASN1_DER_ERROR;
str_len = asn1_get_length_der (der, der_len, &len_len);
if (str_len <= 0 || str_size < str_len)
return ASN1_DER_ERROR;
/* perform some sanity checks on the data */
if (str_len < 8)
{
warn();
return ASN1_DER_ERROR;
}
if (flags & ASN1_DECODE_FLAG_STRICT_DER)
{
p = &der[len_len];
for (i=0;i<(unsigned)(str_len-1);i++)
{
if (isdigit(p[i]) == 0)
{
if (type == ASN1_ETYPE_GENERALIZED_TIME)
{
/* tolerate lax encodings */
if (p[i] == '.' && dot_count == 0)
{
dot_count++;
continue;
}
/* This is not really valid DER, but there are
* structures using that */
if (!(flags & ASN1_DECODE_FLAG_STRICT_DER) &&
(p[i] == '+' || p[i] == '-') && sign_count == 0)
{
sign_count++;
continue;
}
}
warn();
return ASN1_DER_ERROR;
}
}
if (sign_count == 0 && p[str_len-1] != 'Z')
{
warn();
return ASN1_DER_ERROR;
}
}
memcpy (str, der + len_len, str_len);
str[str_len] = 0;
*ret_len = str_len + len_len;
return ASN1_SUCCESS;
}
| @@ -767,10 +767,17 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
if (len2 == -1)
- counter_end = der_len - 2;
+ {
+ if (der_len < 2)
+ return ASN1_DER_ERROR;
+ counter_end = der_len - 2;
+ }
else
counter_end = der_len;
+ if (counter_end < counter)
+ return ASN1_DER_ERROR;
+
while (counter < counter_end)
{
DECR_LEN(der_len, 1); | CWE-399 | null | null |
8,998 | asn1_decode_simple_ber (unsigned int etype, const unsigned char *der,
unsigned int _der_len, unsigned char **str,
unsigned int *str_len, unsigned int *ber_len)
{
int tag_len, len_len;
const unsigned char *p;
int der_len = _der_len;
uint8_t *total = NULL;
unsigned total_size = 0;
unsigned char class;
unsigned long tag;
unsigned char *out = NULL;
unsigned out_len;
long ret;
if (ber_len) *ber_len = 0;
if (der == NULL || der_len == 0)
{
warn();
return ASN1_VALUE_NOT_VALID;
}
if (ETYPE_OK (etype) == 0)
{
warn();
return ASN1_VALUE_NOT_VALID;
}
/* doesn't handle constructed classes */
if (ETYPE_CLASS (etype) != ASN1_CLASS_UNIVERSAL)
{
warn();
return ASN1_VALUE_NOT_VALID;
}
p = der;
ret = asn1_get_tag_der (p, der_len, &class, &tag_len, &tag);
if (ret != ASN1_SUCCESS)
{
warn();
return ret;
}
if (ber_len) *ber_len += tag_len;
if (tag != ETYPE_TAG (etype))
{
warn();
return ASN1_DER_ERROR;
}
p += tag_len;
der_len -= tag_len;
if (der_len <= 0)
return ASN1_DER_ERROR;
if (class == ASN1_CLASS_STRUCTURED && ETYPE_IS_STRING(etype))
{
len_len = 1;
if (p[0] != 0x80)
{
warn();
return ASN1_DER_ERROR;
}
p += len_len;
der_len -= len_len;
if (der_len <= 0)
return ASN1_DER_ERROR;
if (ber_len) *ber_len += len_len;
/* decode the available octet strings */
do
{
unsigned tmp_len;
ret = asn1_decode_simple_ber(etype, p, der_len, &out, &out_len, &tmp_len);
if (ret != ASN1_SUCCESS)
{
free(total);
return ret;
}
p += tmp_len;
der_len -= tmp_len;
if (ber_len) *ber_len += tmp_len;
if (der_len < 2) /* we need the EOC */
{
free(total);
return ASN1_DER_ERROR;
}
if (out_len > 0)
{
ret = append(&total, &total_size, out, out_len);
free(out);
if (ret != ASN1_SUCCESS)
{
free(total);
return ret;
}
}
if (p[0] == 0 && p[1] == 0) /* EOC */
{
if (ber_len) *ber_len += 2;
break;
}
}
while(1);
}
else if (class == ETYPE_CLASS(etype))
{
if (ber_len)
{
ret = asn1_get_length_der (p, der_len, &len_len);
if (ret < 0)
{
warn();
return ASN1_DER_ERROR;
}
*ber_len += ret + len_len;
}
/* non-string values are decoded as DER */
ret = asn1_decode_simple_der(etype, der, _der_len, (const unsigned char**)&out, &out_len);
if (ret != ASN1_SUCCESS)
return ret;
ret = append(&total, &total_size, out, out_len);
if (ret != ASN1_SUCCESS)
return ret;
}
else
return ASN1_DER_ERROR;
*str = total;
*str_len = total_size;
return ASN1_SUCCESS;
}
| DoS | 0 | asn1_decode_simple_ber (unsigned int etype, const unsigned char *der,
unsigned int _der_len, unsigned char **str,
unsigned int *str_len, unsigned int *ber_len)
{
int tag_len, len_len;
const unsigned char *p;
int der_len = _der_len;
uint8_t *total = NULL;
unsigned total_size = 0;
unsigned char class;
unsigned long tag;
unsigned char *out = NULL;
unsigned out_len;
long ret;
if (ber_len) *ber_len = 0;
if (der == NULL || der_len == 0)
{
warn();
return ASN1_VALUE_NOT_VALID;
}
if (ETYPE_OK (etype) == 0)
{
warn();
return ASN1_VALUE_NOT_VALID;
}
/* doesn't handle constructed classes */
if (ETYPE_CLASS (etype) != ASN1_CLASS_UNIVERSAL)
{
warn();
return ASN1_VALUE_NOT_VALID;
}
p = der;
ret = asn1_get_tag_der (p, der_len, &class, &tag_len, &tag);
if (ret != ASN1_SUCCESS)
{
warn();
return ret;
}
if (ber_len) *ber_len += tag_len;
if (tag != ETYPE_TAG (etype))
{
warn();
return ASN1_DER_ERROR;
}
p += tag_len;
der_len -= tag_len;
if (der_len <= 0)
return ASN1_DER_ERROR;
if (class == ASN1_CLASS_STRUCTURED && ETYPE_IS_STRING(etype))
{
len_len = 1;
if (p[0] != 0x80)
{
warn();
return ASN1_DER_ERROR;
}
p += len_len;
der_len -= len_len;
if (der_len <= 0)
return ASN1_DER_ERROR;
if (ber_len) *ber_len += len_len;
/* decode the available octet strings */
do
{
unsigned tmp_len;
ret = asn1_decode_simple_ber(etype, p, der_len, &out, &out_len, &tmp_len);
if (ret != ASN1_SUCCESS)
{
free(total);
return ret;
}
p += tmp_len;
der_len -= tmp_len;
if (ber_len) *ber_len += tmp_len;
if (der_len < 2) /* we need the EOC */
{
free(total);
return ASN1_DER_ERROR;
}
if (out_len > 0)
{
ret = append(&total, &total_size, out, out_len);
free(out);
if (ret != ASN1_SUCCESS)
{
free(total);
return ret;
}
}
if (p[0] == 0 && p[1] == 0) /* EOC */
{
if (ber_len) *ber_len += 2;
break;
}
}
while(1);
}
else if (class == ETYPE_CLASS(etype))
{
if (ber_len)
{
ret = asn1_get_length_der (p, der_len, &len_len);
if (ret < 0)
{
warn();
return ASN1_DER_ERROR;
}
*ber_len += ret + len_len;
}
/* non-string values are decoded as DER */
ret = asn1_decode_simple_der(etype, der, _der_len, (const unsigned char**)&out, &out_len);
if (ret != ASN1_SUCCESS)
return ret;
ret = append(&total, &total_size, out, out_len);
if (ret != ASN1_SUCCESS)
return ret;
}
else
return ASN1_DER_ERROR;
*str = total;
*str_len = total_size;
return ASN1_SUCCESS;
}
| @@ -767,10 +767,17 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
if (len2 == -1)
- counter_end = der_len - 2;
+ {
+ if (der_len < 2)
+ return ASN1_DER_ERROR;
+ counter_end = der_len - 2;
+ }
else
counter_end = der_len;
+ if (counter_end < counter)
+ return ASN1_DER_ERROR;
+
while (counter < counter_end)
{
DECR_LEN(der_len, 1); | CWE-399 | null | null |
8,999 | asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
char *errorDescription)
{
return asn1_der_decoding2 (element, ider, &ider_len, 0, errorDescription);
}
| DoS | 0 | asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
char *errorDescription)
{
return asn1_der_decoding2 (element, ider, &ider_len, 0, errorDescription);
}
| @@ -767,10 +767,17 @@ _asn1_extract_der_octet (asn1_node node, const unsigned char *der,
DECR_LEN(der_len, len3);
if (len2 == -1)
- counter_end = der_len - 2;
+ {
+ if (der_len < 2)
+ return ASN1_DER_ERROR;
+ counter_end = der_len - 2;
+ }
else
counter_end = der_len;
+ if (counter_end < counter)
+ return ASN1_DER_ERROR;
+
while (counter < counter_end)
{
DECR_LEN(der_len, 1); | CWE-399 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.