summaryrefslogtreecommitdiffstats
path: root/rpminfo.c
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2021-06-18 15:38:04 +0200
committerRemi Collet <remi@remirepo.net>2021-06-18 15:38:04 +0200
commit0b1615d804c778516c8c9ed458b69d7a70aea5bb (patch)
tree45708027800c113a933652bc7af240cc3cab7150 /rpminfo.c
parentdf9c1b8603b19d16247965f85b385004ce4a0335 (diff)
raise exception on bad parameter value with PHP 8
and bump version to 0.6
Diffstat (limited to 'rpminfo.c')
-rw-r--r--rpminfo.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/rpminfo.c b/rpminfo.c
index cd6c040..53b9c6c 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -39,7 +39,7 @@
#endif
#ifndef RETURN_THROWS
-#define RETURN_THROWS return
+#define RETURN_THROWS() return
#endif
#include "rpminfo_arginfo.h"
@@ -375,18 +375,50 @@ PHP_FUNCTION(rpmdbsearch)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|llb", &name, &len, &crit, &mode, &full) == FAILURE) {
RETURN_THROWS();
}
+ if (rpmTagGetType(crit) == RPM_NULL_TYPE) {
+#if PHP_VERSION_ID < 80000
+ php_error_docref(NULL, E_WARNING, "Unkown rpmtag");
+ RETURN_NULL();
+#else
+ zend_argument_value_error(2, "Unkown rpmtag");
+ RETURN_THROWS();
+#endif
+ }
+ if (mode != RPMMIRE_DEFAULT &&
+ mode != RPMMIRE_STRCMP &&
+ mode != RPMMIRE_REGEX &&
+ mode != RPMMIRE_GLOB &&
+ mode != -1) {
+#if PHP_VERSION_ID < 80000
+ php_error_docref(NULL, E_WARNING, "Unkown rpmmire");
+ RETURN_NULL();
+#else
+ zend_argument_value_error(3, "Unkown rpmmire");
+ RETURN_THROWS();
+#endif
+ }
if (crit == RPMTAG_PKGID) {
if (len != 32) {
+#if PHP_VERSION_ID < 80000
php_error_docref(NULL, E_WARNING, "Bad length for PKGID, 32 expected");
RETURN_NULL();
+#else
+ zend_argument_value_error(1, "Bad length for PKGID, 32 expected");
+ RETURN_THROWS();
+#endif
}
len = hex2bin(name, MD5, len);
name = MD5;
} else if (crit == RPMTAG_HDRID) {
if (len != 40) {
+#if PHP_VERSION_ID < 80000
php_error_docref(NULL, E_WARNING, "Bad length for HDRID, 40 expected");
RETURN_NULL();
+#else
+ zend_argument_value_error(1, "Bad length for HDRID, 40 expected");
+ RETURN_THROWS();
+#endif
}
} else if (crit == RPMTAG_INSTALLTID) {
tid = atol(name);
@@ -510,6 +542,16 @@ PHP_FUNCTION(rpmaddtag)
RETURN_THROWS();
}
+ if (rpmTagGetType(tag) == RPM_NULL_TYPE) {
+#if PHP_VERSION_ID < 80000
+ php_error_docref(NULL, E_WARNING, "Unkown rpmtag");
+ RETURN_BOOL(0);
+#else
+ zend_argument_value_error(1, "Unkown rpmtag");
+ RETURN_THROWS();
+#endif
+ }
+
if (RPMINFO_G(tags)) {
for (i=0 ; i<RPMINFO_G(nb_tags) ; i++) {
if (RPMINFO_G(tags)[i] == tag) {