]> granicus.if.org Git - php/commitdiff
fixed typos in tests
authorBoris Lytochkin <lytboris@php.net>
Tue, 10 May 2011 20:04:26 +0000 (20:04 +0000)
committerBoris Lytochkin <lytboris@php.net>
Tue, 10 May 2011 20:04:26 +0000 (20:04 +0000)
ucd-snmp epoch is over, drop legacy memory allocation (non e*)
tune 'buggy snmp_snprint_value' detection on some systems

ext/snmp/config.m4
ext/snmp/snmp.c
ext/snmp/tests/snmp-object-errno-errstr.phpt
ext/snmp/tests/wrong_hostname.phpt

index 3a49b7de39f6ea2ac7ab6143946a612aff414f70..ccb7eea9a7bc5b72d8ca820d56b53660f763c248 100644 (file)
@@ -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>
index 1d9beb042cac32cc4e284ddabff74a14f48dd20e..d9a2a032310c3d51d25f37fbcabf17860419e806 100644 (file)
@@ -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;
index e01be63007e95e7f8ddf88d5074d2b57caabddc5..f46254ed3443ea330a643a90cb5ed42cb56ab3e6 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--                                 
-OO API: getErrno & getError functions
+OO API: getErrno & getError methods
 --CREDITS--
 Boris Lytochkin
 --SKIPIF--
index 1227318078cbf1fc6e5b16bea0db48e1c6ba7f99..e0bfa8a54d120559f0ba23c9041df32a5563587a 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--                                 
-Generic timeout (wrong community)
+Wrong hostname
 --CREDITS--
 Boris Lytochkin
 --SKIPIF--