-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of modifying the zval, we use the zend_try_get_string. close GH-16969
- Loading branch information
Showing
3 changed files
with
133 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--TEST-- | ||
snmpget() modifies object_id array source | ||
--EXTENSIONS-- | ||
snmp | ||
--SKIPIF-- | ||
<?php | ||
require_once(__DIR__.'/skipif.inc'); | ||
?> | ||
--FILE-- | ||
<?php | ||
require_once(__DIR__.'/snmp_include.inc'); | ||
|
||
$bad_object_ids = array ( | ||
077 => 077, -066 => -066, -0345 => -0345, 0 => 0 | ||
); | ||
var_dump($bad_object_ids); | ||
var_dump(snmpget($hostname, "", $bad_object_ids) === false); | ||
// The array should remain unmodified | ||
var_dump($bad_object_ids); | ||
try { | ||
snmpget($hostname, "", [0 => new stdClass()]); | ||
} catch (Throwable $e) { | ||
echo $e->getMessage() . PHP_EOL; | ||
} | ||
|
||
try { | ||
snmp2_set($hostname, $communityWrite, $bad_object_ids, array(new stdClass()), array(null)); | ||
} catch (Throwable $e) { | ||
echo $e->getMessage() . PHP_EOL; | ||
} | ||
try { | ||
snmp2_set($hostname, $communityWrite, $bad_object_ids, array("toolongtype"), array(null)); | ||
} catch (Throwable $e) { | ||
echo $e->getMessage() . PHP_EOL; | ||
} | ||
try { | ||
snmp2_set($hostname, $communityWrite, $bad_object_ids, array(str_repeat("onetoomuch", random_int(1, 1))), array(null)); | ||
} catch (Throwable $e) { | ||
echo $e->getMessage(); | ||
} | ||
?> | ||
--EXPECTF-- | ||
array(4) { | ||
[63]=> | ||
int(63) | ||
[-54]=> | ||
int(-54) | ||
[-229]=> | ||
int(-229) | ||
[0]=> | ||
int(0) | ||
} | ||
|
||
Warning: snmpget(): Invalid object identifier: -54 in %s on line %d | ||
bool(true) | ||
array(4) { | ||
[63]=> | ||
int(63) | ||
[-54]=> | ||
int(-54) | ||
[-229]=> | ||
int(-229) | ||
[0]=> | ||
int(0) | ||
} | ||
Object of class stdClass could not be converted to string | ||
Object of class stdClass could not be converted to string | ||
Type must be a single character | ||
Type must be a single character |