7-Jun-2004 Mike Slifcak

This patch fixes a problem with a non-existent structure member
seen during a build on FreeBSD 5.x platform.

Builds on FreeBSD 4.x and FreeBSD 5.x are affected.

Note the memcpy near line 612. The intent is to address one element
in a large array for the purpose of copying it to the nnew buffer.
Did the original memcpy work correctly ??
More importantly, would the new memcpy suffice ?

If FreeBSD 4.9-RELEASE builds clean with this patch, I would
like to incorporate it into the V5-1-patches and main CVS branches.

Best Regards,
-Mike Slifcak


--- net-snmp-5.1.1/agent/mibgroup/mibII/udpTable.c      2004-04-07 00:59:27.000000000 
-0400
+++ net-snmp/agent/mibgroup/mibII/udpTable.c    2004-06-08 00:20:41.617629952 -0400
@@ -65,9 +65,22 @@
 #ifdef linux
 #define INP_NEXT_SYMBOL                inp_next
 #endif
+
+#ifdef freebsd4
+typedef struct netsnmp_inpcb_s netsnmp_inpcb;
+struct netsnmp_inpcb_s {
+    struct inpcb    pcb;
+    int             state;
+    netsnmp_inpcb  *inp_next;
+};
+#define        UDPTABLE_ENTRY_TYPE     netsnmp_inpcb 
+#define        UDPTABLE_LOCALADDRESS   pcb.inp_laddr.s_addr 
+#define        UDPTABLE_LOCALPORT      pcb.inp_lport
+#else
 #define        UDPTABLE_ENTRY_TYPE     struct inpcb 
 #define        UDPTABLE_LOCALADDRESS   inp_laddr.s_addr 
 #define        UDPTABLE_LOCALPORT      inp_lport
+#endif
 #define        UDPTABLE_IS_LINKED_LIST
 
 #endif                          /* WIN32 */
@@ -583,7 +596,7 @@
     int      sname[] = { CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_PCBLIST };
     char     *udpcb_buf = NULL;
     struct xinpgen *xig = NULL;
-    struct inpcb   *nnew;
+    UDPTABLE_ENTRY_TYPE  *nnew;
 
     udpTable_free(NULL, NULL);
 
@@ -607,12 +620,17 @@
     xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
 
     while (xig && (xig->xig_len > sizeof(struct xinpgen))) {
-        nnew = SNMP_MALLOC_TYPEDEF(struct inpcb);
+        nnew = SNMP_MALLOC_TYPEDEF(UDPTABLE_ENTRY_TYPE);
         if (!nnew)
             break;
+#ifdef freebsd4
+        memcpy(nnew, &((struct xinpcb *) xig)->xi_inp, sizeof(struct inpcb));
+       nnew->inp_next = udp_head;
+#else
         memcpy(nnew, ((struct xinpcb *) xig)->xi_inp, sizeof(struct inpcb));
-
        nnew->next = udp_head;          /* XXX - ?? Check 'next' pointer */
+#endif
+
        udp_head   = nnew;
         xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
     }

Reply via email to