@@ -842,21 +842,11 @@ static bool snmp_session_init(php_snmp_session **session_p, int version, zend_st
842842 ZEND_ASSERT (hostname != NULL );
843843 ZEND_ASSERT (community != NULL );
844844
845- if (zend_str_has_nul_byte (hostname )) {
846- zend_argument_value_error (hostname_argument_offset , "must not contain any null bytes" );
847- return false;
848- }
849-
850845 if (ZSTR_LEN (hostname ) >= MAX_NAME_LEN ) {
851846 zend_argument_value_error (hostname_argument_offset , "length must be lower than %d" , MAX_NAME_LEN );
852847 return false;
853848 }
854849
855- if (zend_str_has_nul_byte (community )) {
856- zend_argument_value_error (hostname_argument_offset + 1 , "must not contain any null bytes" );
857- return false;
858- }
859-
860850 if (ZSTR_LEN (community ) == 0 ) {
861851 zend_argument_must_not_be_empty_error (hostname_argument_offset + 1 );
862852 return false;
@@ -1145,7 +1135,10 @@ static bool snmp_session_set_contextEngineID(struct snmp_session *s, zend_string
11451135}
11461136/* }}} */
11471137
1148- /* {{{ Set all snmpv3-related security options */
1138+ /* {{{ Set all snmpv3-related security options
1139+ * auth_protocol_argnum and contextEngineID_argument_offset are the userland
1140+ * argument numbers used for error reporting.
1141+ */
11491142static ZEND_ATTRIBUTE_NONNULL_ARGS (2 ) bool snmp_session_set_security (struct snmp_session * session , zend_string * sec_level ,
11501143 zend_string * auth_protocol , zend_string * auth_passphrase , zend_string * priv_protocol ,
11511144 zend_string * priv_passphrase , zend_string * contextName , zend_string * contextEngineID ,
@@ -1256,8 +1249,8 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
12561249 if (version == SNMP_VERSION_3 ) {
12571250 if (st & SNMP_CMD_SET ) {
12581251 ZEND_PARSE_PARAMETERS_START (10 , 12 )
1259- Z_PARAM_STR (a1 )
1260- Z_PARAM_STR (a2 )
1252+ Z_PARAM_PATH_STR (a1 )
1253+ Z_PARAM_PATH_STR (a2 )
12611254 Z_PARAM_STR (a3 )
12621255 Z_PARAM_STR (a4 )
12631256 Z_PARAM_STR (a5 )
@@ -1281,8 +1274,8 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
12811274 * SNMP_CMD_WALK
12821275 */
12831276 ZEND_PARSE_PARAMETERS_START (8 , 10 )
1284- Z_PARAM_STR (a1 )
1285- Z_PARAM_STR (a2 )
1277+ Z_PARAM_PATH_STR (a1 )
1278+ Z_PARAM_PATH_STR (a2 )
12861279 Z_PARAM_STR (a3 )
12871280 Z_PARAM_STR (a4 )
12881281 Z_PARAM_STR (a5 )
@@ -1300,8 +1293,8 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
13001293 } else {
13011294 if (st & SNMP_CMD_SET ) {
13021295 ZEND_PARSE_PARAMETERS_START (5 , 7 )
1303- Z_PARAM_STR (a1 )
1304- Z_PARAM_STR (a2 )
1296+ Z_PARAM_PATH_STR (a1 )
1297+ Z_PARAM_PATH_STR (a2 )
13051298 Z_PARAM_ARRAY_HT_OR_STR (oid_ht , oid_str )
13061299 Z_PARAM_ARRAY_HT_OR_STR (type_ht , type_str )
13071300 Z_PARAM_ARRAY_HT_OR_STR (value_ht , value_str )
@@ -1320,8 +1313,8 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
13201313 * SNMP_CMD_WALK
13211314 */
13221315 ZEND_PARSE_PARAMETERS_START (3 , 5 )
1323- Z_PARAM_STR (a1 )
1324- Z_PARAM_STR (a2 )
1316+ Z_PARAM_PATH_STR (a1 )
1317+ Z_PARAM_PATH_STR (a2 )
13251318 Z_PARAM_ARRAY_HT_OR_STR (oid_ht , oid_str )
13261319 Z_PARAM_OPTIONAL
13271320 Z_PARAM_LONG (timeout )
@@ -1384,7 +1377,7 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version)
13841377 if (version == SNMP_VERSION_3 && !snmp_session_set_security (session , a3 , a4 , a5 , a6 , a7 , NULL , NULL , 4 , 0 )) {
13851378 php_free_objid_query (& objid_query , oid_ht , value_ht , st );
13861379 snmp_session_free (& session );
1387- /* Warning message sent already, just bail out */
1380+ /* An error has already been emitted , just bail out. */
13881381 RETURN_FALSE ;
13891382 }
13901383 } else {
@@ -1657,9 +1650,14 @@ PHP_METHOD(SNMP, __construct)
16571650
16581651 snmp_object = Z_SNMP_P (object );
16591652
1660- if (zend_parse_parameters (ZEND_NUM_ARGS (), "lSS|ll" , & version , & a1 , & a2 , & timeout , & retries ) == FAILURE ) {
1661- RETURN_THROWS ();
1662- }
1653+ ZEND_PARSE_PARAMETERS_START (3 , 5 )
1654+ Z_PARAM_LONG (version )
1655+ Z_PARAM_PATH_STR (a1 )
1656+ Z_PARAM_PATH_STR (a2 )
1657+ Z_PARAM_OPTIONAL
1658+ Z_PARAM_LONG (timeout )
1659+ Z_PARAM_LONG (retries )
1660+ ZEND_PARSE_PARAMETERS_END ();
16631661
16641662 switch (version ) {
16651663 case SNMP_VERSION_1 :
@@ -1750,8 +1748,9 @@ PHP_METHOD(SNMP, setSecurity)
17501748 RETURN_THROWS ();
17511749 }
17521750
1751+ /* authProtocol is argument #2 and contextEngineId is argument #7. */
17531752 if (!snmp_session_set_security (snmp_object -> session , a1 , a2 , a3 , a4 , a5 , a6 , a7 , 2 , 7 )) {
1754- /* Warning message sent already, just bail out */
1753+ /* An error has already been emitted , just bail out. */
17551754 RETURN_FALSE ;
17561755 }
17571756 RETURN_TRUE ;
0 commit comments