diff options
author | Boris Lytochkin <lytboris@php.net> | 2011-05-10 20:04:26 +0000 |
---|---|---|
committer | Boris Lytochkin <lytboris@php.net> | 2011-05-10 20:04:26 +0000 |
commit | dbed284039fe4fcffdd6f42ff93a0303ee499a59 (patch) | |
tree | 55e2a091b14f7f43a41ccead7810516000eb2b32 | |
parent | b966897a0d7412e0ded08e762aacf52000c8287e (diff) | |
download | php-git-dbed284039fe4fcffdd6f42ff93a0303ee499a59.tar.gz |
fixed typos in tests
ucd-snmp epoch is over, drop legacy memory allocation (non e*)
tune 'buggy snmp_snprint_value' detection on some systems
-rw-r--r-- | ext/snmp/config.m4 | 2 | ||||
-rw-r--r-- | ext/snmp/snmp.c | 24 | ||||
-rw-r--r-- | ext/snmp/tests/snmp-object-errno-errstr.phpt | 2 | ||||
-rw-r--r-- | ext/snmp/tests/wrong_hostname.phpt | 2 |
4 files changed, 19 insertions, 11 deletions
diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index 3a49b7de39..ccb7eea9a7 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -62,7 +62,7 @@ if test "$PHP_SNMP" != "no"; then dnl Check for buggy snmp_snprint_value() (net-snmp BUGid 2027834) AC_CACHE_CHECK([for buggy snmp_snprint_value], ac_cv_buggy_snprint_value,[ save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -I${SNMP_PREFIX}/include" + CFLAGS="$CFLAGS -I${SNMP_PREFIX}/include $SNMP_SHARED_LIBADD" AC_TRY_RUN( [ #include <stdio.h> #include <stdlib.h> diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 1d9beb042c..d9a2a03231 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -440,12 +440,20 @@ static PHP_GINIT_FUNCTION(snmp) } /* }}} */ +#define PHP_SNMP_SESSION_FREE(a) { \ + if ((*session)->a) { \ + efree((*session)->a); \ + (*session)->a = NULL; \ + } \ +} + static void netsnmp_session_free(php_snmp_session **session) { if (*session) { - if ((*session)->peername) { - efree((*session)->peername); - } + PHP_SNMP_SESSION_FREE(peername); + PHP_SNMP_SESSION_FREE(community); + PHP_SNMP_SESSION_FREE(securityName); + PHP_SNMP_SESSION_FREE(contextEngineID); efree(*session); *session = NULL; } @@ -1115,11 +1123,11 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char if (version == SNMP_VERSION_3) { /* Setting the security name. */ - session->securityName = strdup(community); + session->securityName = estrdup(community); session->securityNameLen = strlen(session->securityName); } else { session->authenticator = NULL; - session->community = (u_char *)community; + session->community = (u_char *)estrdup(community); session->community_len = strlen(community); } @@ -1222,7 +1230,7 @@ static int netsnmp_session_gen_sec_key(struct snmp_session *s, char *pass TSRMLS static int netsnmp_session_set_contextEngineID(struct snmp_session *s, char * contextEngineID TSRMLS_DC) { size_t ebuf_len = 32, eout_len = 0; - u_char *ebuf = (u_char *) malloc(ebuf_len); /* memory freed by SNMP library, malloc NOT emalloc */ + u_char *ebuf = (u_char *) emalloc(ebuf_len); if (ebuf == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "malloc failure setting contextEngineID"); @@ -1230,12 +1238,12 @@ static int netsnmp_session_set_contextEngineID(struct snmp_session *s, char * co } if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, contextEngineID)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad engine ID value '%s'", contextEngineID); - free(ebuf); + efree(ebuf); return (-1); } if (s->contextEngineID) { - free(s->contextEngineID); + efree(s->contextEngineID); } s->contextEngineID = ebuf; diff --git a/ext/snmp/tests/snmp-object-errno-errstr.phpt b/ext/snmp/tests/snmp-object-errno-errstr.phpt index e01be63007..f46254ed34 100644 --- a/ext/snmp/tests/snmp-object-errno-errstr.phpt +++ b/ext/snmp/tests/snmp-object-errno-errstr.phpt @@ -1,5 +1,5 @@ --TEST-- -OO API: getErrno & getError functions +OO API: getErrno & getError methods --CREDITS-- Boris Lytochkin --SKIPIF-- diff --git a/ext/snmp/tests/wrong_hostname.phpt b/ext/snmp/tests/wrong_hostname.phpt index 1227318078..e0bfa8a54d 100644 --- a/ext/snmp/tests/wrong_hostname.phpt +++ b/ext/snmp/tests/wrong_hostname.phpt @@ -1,5 +1,5 @@ --TEST-- -Generic timeout (wrong community) +Wrong hostname --CREDITS-- Boris Lytochkin --SKIPIF-- |