]> granicus.if.org Git - php/commitdiff
do not allow negative byte index
authorAntony Dovgal <tony2001@php.net>
Wed, 18 Apr 2007 20:36:47 +0000 (20:36 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 18 Apr 2007 20:36:47 +0000 (20:36 +0000)
tests will follow soon

ext/gmp/gmp.c

index 9798578eaba4435b75b9b03bbed0a955e6ccfed5..68ce034547235c982476175c225608be9b01c99f 100644 (file)
@@ -1492,6 +1492,11 @@ ZEND_FUNCTION(gmp_setbit)
                        break;
        }
 
+       if (index < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to zero");
+               return;
+       }
+
        if (set) {
                mpz_setbit(*gmpnum_a, index);
        } else {
@@ -1516,6 +1521,11 @@ ZEND_FUNCTION(gmp_clrbit)
 
        convert_to_long_ex(ind_arg);
        index = Z_LVAL_PP(ind_arg);
+       
+       if (index < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to zero");
+               return;
+       }
 
        mpz_clrbit(*gmpnum_a, index);
 }