15793150 SUNBT7170603 libnetsnmp free_slots frees things it doesn't own
authorAshik Ratnani <ashik.ratnani@oracle.com>
Mon, 22 Apr 2013 13:51:56 -0700
changeset 1278 5a3949922d70
parent 1277 0c751970523d
child 1279 ff655280d936
15793150 SUNBT7170603 libnetsnmp free_slots frees things it doesn't own
components/net-snmp/patches/002.pkcs.patch
--- a/components/net-snmp/patches/002.pkcs.patch	Mon Apr 22 15:18:52 2013 +0200
+++ b/components/net-snmp/patches/002.pkcs.patch	Mon Apr 22 13:51:56 2013 -0700
@@ -1,28 +1,34 @@
---- net-snmp-5.4.1/snmplib/pkcs.c	Tue Nov  6 02:00:04 2007
-+++ net-snmp-5.4.1/snmplib/pkcs.mod.c	Tue Nov  6 01:58:30 2007
+Following patch is a fix for a bug in libnetsnmp which, under certain
+circumstances, causes a core dump during snmp_shutdown.
+
+(Upstream Bug) #2374 net-snmp is coring when stopped
+=====================================================================
+--- net-snmp-5.4.1/snmplib/pkcs.c	Tue Mar  5 17:29:50 2013
++++ net-snmp-5.4.1/snmplib/pkcs.mod.c	Tue Mar  5 17:35:30 2013
 @@ -1,5 +1,5 @@
  /*
 - * Copyright Copyright 2003 Sun Microsystems, Inc. All rights reserved.
-+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   * Use is subject to license terms specified in the COPYING file
   * distributed with the Net-SNMP package.
   */
-@@ -107,10 +107,12 @@
+@@ -105,19 +105,13 @@
+ static int
+ free_slots(int majorID, int minorID, void *serverarg, void *clientarg)
  {
-     int            slotcount, i;
+-    int            slotcount, i;
++    (void) C_Finalize(NULL);
  
-+    (void) C_Finalize(NULL);
-+
      if (pSlot != NULL) {
-         slotcount = pSlot->count;
-         for (i = 0; i < slotcount; i++) {
+-        slotcount = pSlot->count;
+-        for (i = 0; i < slotcount; i++) {
 -            if (pSlot->pSession->hdl != NULL) {
-+            if (pSlot->pSession != NULL) {
-                 free(pSlot->pSession->hdl);
-             }
-         }
-@@ -117,7 +119,6 @@
-         free(pSlot);
+-                free(pSlot->pSession->hdl);
+-            }
+-        }
+-        free(pSlot);
++        SNMP_FREE(pSlot->pSession);
++        SNMP_FREE(pSlot);
      }
  
 -    (void) C_Finalize(NULL);