summaryrefslogtreecommitdiff
path: root/execute.c
diff options
context:
space:
mode:
authorStefan2010-03-24 14:03:00 +0100
committerStefan2010-03-24 14:03:00 +0100
commit123e88789441ac5e1c8edeadcfb5c495d2b8f409 (patch)
treef066c4da105fad6873fb7979ff452dcf540f8157 /execute.c
parentc54d1f40594b6bc592dc22e55b7683b2ec9ec8c9 (diff)
Fixed error handling in (mt_)srand(), (mt_)getrandmax()
Diffstat (limited to 'execute.c')
-rw-r--r--execute.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/execute.c b/execute.c
index aea108a..9b390b6 100644
--- a/execute.c
+++ b/execute.c
@@ -1394,7 +1394,9 @@ static int ih_srand(IH_HANDLER_PARAMS)
1394 long seed; 1394 long seed;
1395 1395
1396 if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE || SUHOSIN_G(srand_ignore)) { 1396 if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE || SUHOSIN_G(srand_ignore)) {
1397#ifndef PHP_ATLEAST_5_3
1397 RETVAL_FALSE; 1398 RETVAL_FALSE;
1399#endif
1398 return (1); 1400 return (1);
1399 } 1401 }
1400 1402
@@ -1403,7 +1405,9 @@ static int ih_srand(IH_HANDLER_PARAMS)
1403 } else { 1405 } else {
1404 suhosin_srand(seed TSRMLS_CC); 1406 suhosin_srand(seed TSRMLS_CC);
1405 } 1407 }
1408#ifndef PHP_ATLEAST_5_3
1406 RETVAL_TRUE; 1409 RETVAL_TRUE;
1410#endif
1407 return (1); 1411 return (1);
1408} 1412}
1409 1413
@@ -1413,7 +1417,9 @@ static int ih_mt_srand(IH_HANDLER_PARAMS)
1413 long seed; 1417 long seed;
1414 1418
1415 if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE || SUHOSIN_G(mt_srand_ignore)) { 1419 if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE || SUHOSIN_G(mt_srand_ignore)) {
1420#ifndef PHP_ATLEAST_5_3
1416 RETVAL_FALSE; 1421 RETVAL_FALSE;
1422#endif
1417 return (1); 1423 return (1);
1418 } 1424 }
1419 1425
@@ -1422,7 +1428,9 @@ static int ih_mt_srand(IH_HANDLER_PARAMS)
1422 } else { 1428 } else {
1423 suhosin_mt_srand(seed TSRMLS_CC); 1429 suhosin_mt_srand(seed TSRMLS_CC);
1424 } 1430 }
1431#ifndef PHP_ATLEAST_5_3
1425 RETVAL_TRUE; 1432 RETVAL_TRUE;
1433#endif
1426 return (1); 1434 return (1);
1427} 1435}
1428 1436
@@ -1446,7 +1454,8 @@ static int ih_mt_rand(IH_HANDLER_PARAMS)
1446 RAND_RANGE(number, min, max, PHP_MT_RAND_MAX); 1454 RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
1447 } 1455 }
1448 1456
1449 RETURN_LONG(number); 1457 RETVAL_LONG(number);
1458 return (1);
1450} 1459}
1451 1460
1452static int ih_rand(IH_HANDLER_PARAMS) 1461static int ih_rand(IH_HANDLER_PARAMS)
@@ -1469,17 +1478,23 @@ static int ih_rand(IH_HANDLER_PARAMS)
1469 RAND_RANGE(number, min, max, PHP_MT_RAND_MAX); 1478 RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
1470 } 1479 }
1471 1480
1472 RETURN_LONG(number); 1481 RETVAL_LONG(number);
1482 return (1);
1473} 1483}
1474 1484
1475static int ih_getrandmax(IH_HANDLER_PARAMS) 1485static int ih_getrandmax(IH_HANDLER_PARAMS)
1476{ 1486{
1477 int argc = ZEND_NUM_ARGS(); 1487#ifdef PHP_ATLEAST_5_3
1488 if (zend_parse_parameters_none() == FAILURE) {
1489 return;
1490 }
1491#else
1492 int argc = ZEND_NUM_ARGS();
1478 1493
1479 if (argc != 0) { 1494 if (argc != 0) {
1480 ZEND_WRONG_PARAM_COUNT(); 1495 ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(1);
1481 } 1496 }
1482 1497#endif
1483 RETVAL_LONG(PHP_MT_RAND_MAX); 1498 RETVAL_LONG(PHP_MT_RAND_MAX);
1484 return (1); 1499 return (1);
1485} 1500}
@@ -1543,6 +1558,7 @@ internal_function_handler ihandlers[] = {
1543}; 1558};
1544 1559
1545#define FUNCTION_WARNING() zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name(TSRMLS_C)); 1560#define FUNCTION_WARNING() zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name(TSRMLS_C));
1561#define FUNCTION_SIMULATE_WARNING() zend_error(E_WARNING, "SIMULATION - %s() has been disabled for security reasons", get_active_function_name(TSRMLS_C));
1546 1562
1547/* {{{ void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC) 1563/* {{{ void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC)
1548 * This function provides a hook for internal execution */ 1564 * This function provides a hook for internal execution */
@@ -1590,6 +1606,8 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re
1590 suhosin_log(S_EXECUTOR, "function outside of eval whitelist called: %s()", lcname); 1606 suhosin_log(S_EXECUTOR, "function outside of eval whitelist called: %s()", lcname);
1591 if (!SUHOSIN_G(simulation)) { 1607 if (!SUHOSIN_G(simulation)) {
1592 goto execute_internal_bailout; 1608 goto execute_internal_bailout;
1609 } else {
1610 FUNCTION_SIMULATE_WARNING()
1593 } 1611 }
1594 } 1612 }
1595 } else if (SUHOSIN_G(eval_blacklist) != NULL) { 1613 } else if (SUHOSIN_G(eval_blacklist) != NULL) {
@@ -1597,6 +1615,8 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re
1597 suhosin_log(S_EXECUTOR, "function within eval blacklist called: %s()", lcname); 1615 suhosin_log(S_EXECUTOR, "function within eval blacklist called: %s()", lcname);
1598 if (!SUHOSIN_G(simulation)) { 1616 if (!SUHOSIN_G(simulation)) {
1599 goto execute_internal_bailout; 1617 goto execute_internal_bailout;
1618 } else {
1619 FUNCTION_SIMULATE_WARNING()
1600 } 1620 }
1601 } 1621 }
1602 } 1622 }
@@ -1607,6 +1627,8 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re
1607 suhosin_log(S_EXECUTOR, "function outside of whitelist called: %s()", lcname); 1627 suhosin_log(S_EXECUTOR, "function outside of whitelist called: %s()", lcname);
1608 if (!SUHOSIN_G(simulation)) { 1628 if (!SUHOSIN_G(simulation)) {
1609 goto execute_internal_bailout; 1629 goto execute_internal_bailout;
1630 } else {
1631 FUNCTION_SIMULATE_WARNING()
1610 } 1632 }
1611 } 1633 }
1612 } else if (SUHOSIN_G(func_blacklist) != NULL) { 1634 } else if (SUHOSIN_G(func_blacklist) != NULL) {
@@ -1614,6 +1636,8 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re
1614 suhosin_log(S_EXECUTOR, "function within blacklist called: %s()", lcname); 1636 suhosin_log(S_EXECUTOR, "function within blacklist called: %s()", lcname);
1615 if (!SUHOSIN_G(simulation)) { 1637 if (!SUHOSIN_G(simulation)) {
1616 goto execute_internal_bailout; 1638 goto execute_internal_bailout;
1639 } else {
1640 FUNCTION_SIMULATE_WARNING()
1617 } 1641 }
1618 } 1642 }
1619 } 1643 }