lytboris                                 Tue, 10 May 2011 20:04:26 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=310936

Log:
fixed typos in tests
ucd-snmp epoch is over, drop legacy memory allocation (non e*)
tune 'buggy snmp_snprint_value' detection on some systems

Changed paths:
    U   php/php-src/trunk/ext/snmp/config.m4
    U   php/php-src/trunk/ext/snmp/snmp.c
    U   php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt
    U   php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt

Modified: php/php-src/trunk/ext/snmp/config.m4
===================================================================
--- php/php-src/trunk/ext/snmp/config.m4        2011-05-10 19:59:07 UTC (rev 
310935)
+++ php/php-src/trunk/ext/snmp/config.m4        2011-05-10 20:04:26 UTC (rev 
310936)
@@ -62,7 +62,7 @@
   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>

Modified: php/php-src/trunk/ext/snmp/snmp.c
===================================================================
--- php/php-src/trunk/ext/snmp/snmp.c   2011-05-10 19:59:07 UTC (rev 310935)
+++ php/php-src/trunk/ext/snmp/snmp.c   2011-05-10 20:04:26 UTC (rev 310936)
@@ -440,12 +440,20 @@
 }
 /* }}} */

+#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 @@

        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_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 @@
        }
        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;

Modified: php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt
===================================================================
--- php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt      
2011-05-10 19:59:07 UTC (rev 310935)
+++ php/php-src/trunk/ext/snmp/tests/snmp-object-errno-errstr.phpt      
2011-05-10 20:04:26 UTC (rev 310936)
@@ -1,5 +1,5 @@
 --TEST--
-OO API: getErrno & getError functions
+OO API: getErrno & getError methods
 --CREDITS--
 Boris Lytochkin
 --SKIPIF--

Modified: php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt
===================================================================
--- php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt        2011-05-10 
19:59:07 UTC (rev 310935)
+++ php/php-src/trunk/ext/snmp/tests/wrong_hostname.phpt        2011-05-10 
20:04:26 UTC (rev 310936)
@@ -1,5 +1,5 @@
 --TEST--
-Generic timeout (wrong community)
+Wrong hostname
 --CREDITS--
 Boris Lytochkin
 --SKIPIF--

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to