@@ -961,6 +961,10 @@ static bool netsnmp_session_set_sec_level(struct snmp_session *s, zend_string *l
961961/* {{{ Set the authentication protocol in the snmpv3 session */
962962static bool netsnmp_session_set_auth_protocol (struct snmp_session * s , zend_string * prot )
963963{
964+ if (!prot ) {
965+ zend_value_error ("Authentication protocol can't be NULL" );
966+ return false;
967+ }
964968#ifndef DISABLE_MD5
965969 if (zend_string_equals_literal_ci (prot , "MD5" )) {
966970 s -> securityAuthProto = usmHMACMD5AuthProtocol ;
@@ -1013,6 +1017,10 @@ static bool netsnmp_session_set_auth_protocol(struct snmp_session *s, zend_strin
10131017/* {{{ Set the security protocol in the snmpv3 session */
10141018static bool netsnmp_session_set_sec_protocol (struct snmp_session * s , zend_string * prot )
10151019{
1020+ if (!prot ) {
1021+ zend_value_error ("Security protocol can't be NULL" );
1022+ return false;
1023+ }
10161024#ifndef NETSNMP_DISABLE_DES
10171025 if (zend_string_equals_literal_ci (prot , "DES" )) {
10181026 s -> securityPrivProto = usmDESPrivProtocol ;
@@ -1051,6 +1059,12 @@ static bool netsnmp_session_set_sec_protocol(struct snmp_session *s, zend_string
10511059static bool netsnmp_session_gen_auth_key (struct snmp_session * s , zend_string * pass )
10521060{
10531061 int snmp_errno ;
1062+
1063+ if (!pass ) {
1064+ zend_value_error ("Authentication key can't be NULL" );
1065+ return false;
1066+ }
1067+
10541068 s -> securityAuthKeyLen = USM_AUTH_KU_LEN ;
10551069 if ((snmp_errno = generate_Ku (s -> securityAuthProto , s -> securityAuthProtoLen ,
10561070 (uint8_t * ) ZSTR_VAL (pass ), ZSTR_LEN (pass ),
@@ -1067,6 +1081,11 @@ static bool netsnmp_session_gen_sec_key(struct snmp_session *s, zend_string *pas
10671081{
10681082 int snmp_errno ;
10691083
1084+ if (!pass ) {
1085+ zend_value_error ("Security key can't be NULL" );
1086+ return false;
1087+ }
1088+
10701089 s -> securityPrivKeyLen = USM_PRIV_KU_LEN ;
10711090 if ((snmp_errno = generate_Ku (s -> securityAuthProto , s -> securityAuthProtoLen ,
10721091 (uint8_t * )ZSTR_VAL (pass ), ZSTR_LEN (pass ),
0 commit comments