php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32374 Compilation fails with net-snmp 5.2.1
Submitted: 2005-03-19 18:54 UTC Modified: 2005-03-20 01:12 UTC
From: phdokc at cox dot net Assigned:
Status: Not a bug Package: SNMP related
PHP Version: 4.3.10 OS: HP-UX 11.11
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phdokc at cox dot net
New email:
PHP Version: OS:

 

 [2005-03-19 18:54 UTC] phdokc at cox dot net
Description:
------------
After Net-SNMP team supplied patch to net-snmp 5.2 to correct a coredump under certain situations, php 4.3.8 would no longer compile.  4.3.9 had exact problem as 4.3.8.  4.3.10 had an error similar to bug #31121 (way too much error detail to attach but I have it if you want it).  Following #31121 I downloaded CVS snapshot for 200503181930 and 200503191330 and both had a ld error while ld sapi/cli/php.  DSO appeared to ld correctly.  Details of all in Actual Results Section of this bug report (including net-snmp patch - dif.proto).  

ENV is HP-UX 11.11i, GMAKE 3.80, GCC 3.3.3, Apache 2.0.53, MySQL 3.23.58, Net-SNMP 5.2(patched).  Any other questions, please email.  Thanks.

Expected result:
----------------
Successful compile.

Actual result:
--------------
Failure on 4.3.8 and 4.3.9 compile after applying net-snmp 5.2 patch

/bin/sh /backup1/php/php-4.3.8/libtool --silent --preserve-dup-deps --mode=compile /backup1/php/php-4.3.8/meta_ccld  -Iext/snmp/ -I/backup1/php/php-4.3.8/ext/snmp/ -DPHP_ATOM_INC -I/backup1/php/php-4.3.8/include -I/backup1/php/php-4.3.8/main -I/backup1/php/php-4.3.8 -I/backup1/php/php-4.3.8/Zend -I/usr/local/include -I/backup1/php/php-4.3.8/ext/xml/expat  -D_REENTRANT -I/backup1/php/php-4.3.8/TSRM -DTHREAD=1  -g -O2 -pthread -DZTS  -prefer-pic -c /backup1/php/php-4.3.8/ext/snmp/snmp.c -o ext/snmp/snmp.lo
/backup1/php/php-4.3.8/ext/snmp/snmp.c: In function `php_snmp_internal':
/backup1/php/php-4.3.8/ext/snmp/snmp.c:349: warning: passing arg 3 of `snmp_parse_oid' from incompatible pointer type
/backup1/php/php-4.3.8/ext/snmp/snmp.c:389: warning: passing arg 3 of `snmp_parse_oid' from incompatible pointer type
/backup1/php/php-4.3.8/ext/snmp/snmp.c: In function `netsnmp_session_set_sec_protocol':
/backup1/php/php-4.3.8/ext/snmp/snmp.c:777: error: `usmAES192PrivProtocol' undeclared (first use in this function)
/backup1/php/php-4.3.8/ext/snmp/snmp.c:777: error: (Each undeclared identifier is reported only once
/backup1/php/php-4.3.8/ext/snmp/snmp.c:777: error: for each function it appears in.)
/backup1/php/php-4.3.8/ext/snmp/snmp.c:781: error: `usmAES256PrivProtocol' undeclared (first use in this function)
/backup1/php/php-4.3.8/ext/snmp/snmp.c: In function `netsnmp_session_gen_auth_key':
/backup1/php/php-4.3.8/ext/snmp/snmp.c:804: warning: initialization discards qualifiers from pointer target type
/backup1/php/php-4.3.8/ext/snmp/snmp.c: In function `netsnmp_session_gen_sec_key':
/backup1/php/php-4.3.8/ext/snmp/snmp.c:833: warning: initialization discards qualifiers from pointer target type
gmake: *** [ext/snmp/snmp.lo] Error 1


Failure on 4.3.9 compile after applying net-snmp 5.2 patch

/bin/sh /backup1/php/php-4.3.9/libtool --silent --preserve-dup-deps --mode=compile gcc  -Iext/snmp/ -I/backup1/php/php-4.3.9/ext/snmp/ -DPHP_ATOM_INC -I/backup1/php/php-4.3.9/include -I/backup1/php/php-4.3.9/main -I/backup1/php/php-4.3.9 -I/backup1/php/php-4.3.9/Zend -I/usr/local/include -I/backup1/php/php-4.3.9/ext/xml/expat  -I/backup1/php/php-4.3.9/TSRM  -g -O2  -prefer-pic -c /backup1/php/php-4.3.9/ext/snmp/snmp.c -o ext/snmp/snmp.lo 
/backup1/php/php-4.3.9/ext/snmp/snmp.c: In function `php_snmp_internal':
/backup1/php/php-4.3.9/ext/snmp/snmp.c:349: warning: passing arg 3 of `snmp_parse_oid' from incompatible pointer type
/backup1/php/php-4.3.9/ext/snmp/snmp.c:389: warning: passing arg 3 of `snmp_parse_oid' from incompatible pointer type
/backup1/php/php-4.3.9/ext/snmp/snmp.c: In function `netsnmp_session_set_sec_protocol':
/backup1/php/php-4.3.9/ext/snmp/snmp.c:777: error: `usmAES192PrivProtocol' undeclared (first use in this function)
/backup1/php/php-4.3.9/ext/snmp/snmp.c:777: error: (Each undeclared identifier is reported only once
/backup1/php/php-4.3.9/ext/snmp/snmp.c:777: error: for each function it appears in.)
/backup1/php/php-4.3.9/ext/snmp/snmp.c:781: error: `usmAES256PrivProtocol' undeclared (first use in this function)
/backup1/php/php-4.3.9/ext/snmp/snmp.c: In function `netsnmp_session_gen_auth_key':
/backup1/php/php-4.3.9/ext/snmp/snmp.c:804: warning: initialization discards qualifiers from pointer target type
/backup1/php/php-4.3.9/ext/snmp/snmp.c: In function `netsnmp_session_gen_sec_key':
/backup1/php/php-4.3.9/ext/snmp/snmp.c:833: warning: initialization discards qualifiers from pointer target type
gmake: *** [ext/snmp/snmp.lo] Error 1


Last line of failure on 4.3.10 compile after applying net-snmp 5.2 patch


/backup/php/php-4.3.10/Zend/zend_strtod.c:1571: error: dereferencing pointer to incomplete type
gmake: *** [Zend/zend_strtod.lo] Error 1



Failure on CVS Snapshot's php4-STABLE-200503191330 and php4-STABLE-200503181930 (exact same error).

/usr/ccs/bin/ld: Unsatisfied symbols:
   ntohs (code)
collect2: ld returned 1 exit status
gmake: *** [sapi/cli/php] Error 1



net-snmp 5.2 patch dif.proto

Index: include/net-snmp/library/snmp_api.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/library/snmp_api.h,v
retrieving revision 5.11
diff -u -r5.11 snmp_api.h
--- include/net-snmp/library/snmp_api.h 8 Jul 2004 15:36:01 -0000       5.11
+++ include/net-snmp/library/snmp_api.h 14 Mar 2005 23:09:25 -0000
@@ -484,8 +484,9 @@
 #define SNMPERR_VAR_TYPE               (-61)
 #define SNMPERR_MALLOC                 (-62)
 #define SNMPERR_KRB5                   (-63)
+#define SNMPERR_PROTOCOL               (-64)

-#define SNMPERR_MAX                    (-63)
+#define SNMPERR_MAX                    (-64)

 #define non_repeaters  errstat
 #define max_repetitions errindex
Index: snmplib/snmp_api.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/snmp_api.c,v
retrieving revision 5.68
diff -u -r5.68 snmp_api.c
--- snmplib/snmp_api.c  15 Oct 2004 18:52:29 -0000      5.68
+++ snmplib/snmp_api.c  14 Mar 2005 23:09:28 -0000
@@ -295,6 +295,7 @@
     "Bad variable type",        /* SNMPERR_VAR_TYPE */
     "Out of memory (malloc failure)",   /* SNMPERR_MALLOC */
     "Kerberos related error",   /* SNMPERR_KRB5 */
+    "Protocol error",          /* SNMPERR_PROTOCOL */
 };

 static const char *secLevelName[] = {
@@ -496,19 +497,21 @@
 snmp_api_errstring(int snmp_errnumber)
 {
     const char     *msg = "";
-    static char     msg_buf[256];
+    static char     msg_buf[SPRINT_MAX_LEN];
     if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
         msg = api_errors[-snmp_errnumber];
     } else if (snmp_errnumber != SNMPERR_SUCCESS) {
-        msg = "Unknown Error";
+        msg = NULL;
     }
-    if (snmp_detail_f) {
-        snprintf(msg_buf, 256, "%s (%s)", msg, snmp_detail);
+    if (!msg)
+       snprintf(msg_buf, sizeof(msg_buf), "Unknown error: %d", snmp_errnumber);
+    else if (snmp_detail_f) {
+        snprintf(msg_buf, sizeof(msg_buf), "%s (%s)", msg, snmp_detail);
         snmp_detail_f = 0;
     } else {
-        strncpy(msg_buf, msg, 256);
+        strncpy(msg_buf, msg, sizeof(msg_buf));
     }
-    msg_buf[255] = '\0';
+    msg_buf[sizeof(msg_buf)-1] = '\0';

     return (msg_buf);
 }
@@ -535,12 +538,16 @@
     strcpy(buf, "");
     snmp_errnumber = psess->s_snmp_errno;
     if (snmp_errnumber >= SNMPERR_MAX && snmp_errnumber <= SNMPERR_GENERR) {
-        strncpy(buf, api_errors[-snmp_errnumber], 256);
+       if (snmp_detail_f)
+            snprintf(buf, sizeof(buf), "%s (%s)", api_errors[-snmp_errnumber],
+                   snmp_detail);
+       else
+           strncpy(buf, api_errors[-snmp_errnumber], sizeof(buf));
     } else {
         if (snmp_errnumber)
-            snprintf(buf, 256, "Unknown Error %d", snmp_errnumber);
+            snprintf(buf, sizeof(buf), "Unknown Error %d", snmp_errnumber);
     }
-    buf[255] = '\0';
+    buf[sizeof(buf)-1] = '\0';

     /*
      * append a useful system errno interpretation.
@@ -549,10 +556,10 @@
         const char* error = strerror(psess->s_errno);
         if(error == NULL)
             error = "Unknown Error";
-        snprintf (&buf[strlen(buf)], 256-strlen(buf),
+        snprintf (&buf[strlen(buf)], sizeof(buf)-strlen(buf),
                  " (%s)", error);
     }
-    buf[255] = '\0';
+    buf[sizeof(buf)-1] = '\0';
     *p_str = strdup(buf);
 }

@@ -4177,6 +4184,7 @@
     data = asn_parse_header(data, length, &msg_type);
     if (data == NULL)
         return -1;
+    DEBUGMSGTL(("dumpv_recv","    Command 0x%.2x\n", msg_type));
     pdu->command = msg_type;
     pdu->flags &= (~UCD_MSG_FLAG_RESPONSE_PDU);

Index: snmplib/snmp_client.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/snmp_client.c,v
retrieving revision 5.6.2.1
diff -u -r5.6.2.1 snmp_client.c
--- snmplib/snmp_client.c       10 Dec 2004 02:21:38 -0000      5.6.2.1
+++ snmplib/snmp_client.c       14 Mar 2005 23:09:28 -0000
@@ -188,6 +188,16 @@
             state->status = STAT_SUCCESS;
             session->s_snmp_errno = SNMPERR_SUCCESS;
         }
+       else {
+           char msg_buf[50];
+           state->status = STAT_ERROR;
+           session->s_snmp_errno = SNMPERR_PROTOCOL;
+           SET_SNMP_ERROR(SNMPERR_PROTOCOL);
+           snprintf(msg_buf, sizeof(msg_buf), "Expected RESPONSE pdu but got 0x%.2X",
+                   pdu->command);
+           snmp_set_detail(msg_buf);
+          return 0;
+       }
     } else if (op == NETSNMP_CALLBACK_OP_TIMED_OUT) {
         state->pdu = NULL;
         state->status = STAT_TIMEOUT;

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-19 19:00 UTC] phdokc at cox dot net
Sorry, forgot to add config options.  Using same options on all versions to compile.

configure --prefix=/opt/hpws/apache/php --enable-snmp --enable-pcntl --enable-sockets --enable-sigchild --with-snmp --with-snmp-dir=
/usr/local/include/net-snmp --with-gd --with-gd-dir=/usr/local/include --with-mysql --with-mysql-dir=/usr/local/mysql/include --with
-jpeg --with-jpeg-dir=/usr/local/include --with-zlib --with-zlib-dir=/usr/local/include --with-apxs2=/backup1/apache/bin/apxs --with
-png --with-png-dir=/usr/local/include --with-gettext --with-gettext-dir=/usr/local/lib/gettext
 [2005-03-19 21:39 UTC] sniper@php.net
We don't support any patched external libs, we can hardly support really released ones..

 [2005-03-19 22:43 UTC] phdokc at cox dot net
Sorry, should have been clearer.  I backed out the net-snmp 5.2.1 patch and the CVS snap shot and 4.3.10 still will not compile and have the same error results.
 [2005-03-20 01:12 UTC] sniper@php.net
Sorry but this is not PHP bug. Compiles fine for me with latest CVS snapshot.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 13:01:29 2025 UTC