Source: net-snmp
Severity: important
Tags: patch

Please enabled hardened build flags through dpkg-buildflags.

Patch attached. The hardened build flags also exposed many
missing format strings, for which I have attached proposed
patches as well.

Cheers,
        Moritz
--- net-snmp-5.4.3~dfsg.harden/debian/rules	2011-01-05 13:12:04.000000000 +0100
+++ net-snmp-5.4.3~dfsg/debian/rules	2012-01-26 19:55:00.000000000 +0100
@@ -29,6 +29,8 @@
 MIB_MODULES += host
 endif
 
+DEB_CFLAGS_MAINT_APPEND=-DNETSNMP_USE_INLINE
+
 %:
 	dh --with python-central $@
 
@@ -43,7 +45,7 @@
 	dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
 	  --with-persistent-directory=/var/lib/snmp \
 	  --enable-ucd-snmp-compatibility \
-	  --enable-shared --with-cflags="$(CFLAGS) -DNETSNMP_USE_INLINE" \
+	  --enable-shared $(shell dpkg-buildflags --export=configure) \
 	  --with-perl-modules="INSTALLDIRS=vendor" --enable-as-needed \
 	  $(IPV6) --with-logfile=none \
 	  --without-rpm --with-libwrap --with-openssl \
diff -aur net-snmp-5.4.3~dfsg.harden/agent/mibgroup/host/hr_filesys.c net-snmp-5.4.3~dfsg/agent/mibgroup/host/hr_filesys.c
--- net-snmp-5.4.3~dfsg.harden/agent/mibgroup/host/hr_filesys.c	2009-04-24 00:16:22.000000000 +0200
+++ net-snmp-5.4.3~dfsg/agent/mibgroup/host/hr_filesys.c	2012-01-26 20:07:22.000000000 +0100
@@ -316,13 +316,13 @@
         long_return = fsys_idx;
         return (u_char *) & long_return;
     case HRFSYS_MOUNT:
-        snprintf(string, sizeof(string), HRFS_entry->HRFS_mount);
+        snprintf(string, sizeof(string), "%s", HRFS_entry->HRFS_mount);
         string[ sizeof(string)-1 ] = 0;
         *var_len = strlen(string);
         return (u_char *) string;
     case HRFSYS_RMOUNT:
         if (Check_HR_FileSys_NFS()) {
-            snprintf(string, sizeof(string), HRFS_entry->HRFS_name);
+            snprintf(string, sizeof(string), "%s", HRFS_entry->HRFS_name);
             string[ sizeof(string)-1 ] = 0;
         } else
             string[0] = '\0';
Nur in net-snmp-5.4.3~dfsg/agent/mibgroup/host: hr_filesys.c~.
diff -aur net-snmp-5.4.3~dfsg.harden/agent/mibgroup/host/hr_swinst.c net-snmp-5.4.3~dfsg/agent/mibgroup/host/hr_swinst.c
--- net-snmp-5.4.3~dfsg.harden/agent/mibgroup/host/hr_swinst.c	2010-01-26 10:27:30.000000000 +0100
+++ net-snmp-5.4.3~dfsg/agent/mibgroup/host/hr_swinst.c	2012-01-26 20:08:43.000000000 +0100
@@ -695,7 +695,7 @@
         swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
     }
 #else
-    snprintf(swi->swi_name, sizeof(swi->swi_name), swi->swi_dep->d_name);
+    snprintf(swi->swi_name, sizeof(swi->swi_name), "%s", swi->swi_dep->d_name);
     swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
 #endif
     return 0;
Nur in net-snmp-5.4.3~dfsg/agent/mibgroup/host: hr_swinst.c~.
diff -aur net-snmp-5.4.3~dfsg.harden/agent/mibgroup/ucd-snmp/versioninfo.c net-snmp-5.4.3~dfsg/agent/mibgroup/ucd-snmp/versioninfo.c
--- net-snmp-5.4.3~dfsg.harden/agent/mibgroup/ucd-snmp/versioninfo.c	2006-09-15 02:48:50.000000000 +0200
+++ net-snmp-5.4.3~dfsg/agent/mibgroup/ucd-snmp/versioninfo.c	2012-01-26 20:10:34.000000000 +0100
@@ -109,7 +109,7 @@
         long_ret = name[8];
         return ((u_char *) (&long_ret));
     case VERTAG:
-        sprintf(errmsg, netsnmp_get_version());
+        sprintf(errmsg, "%s", netsnmp_get_version());
         *var_len = strlen(errmsg);
         return ((u_char *) errmsg);
     case VERDATE:
@@ -119,7 +119,7 @@
     case VERCDATE:
         curtime = time(NULL);
         cptr = ctime(&curtime);
-        sprintf(errmsg, cptr);
+        sprintf(errmsg, "%s", cptr);
         *var_len = strlen(errmsg) - 1;
         return ((u_char *) errmsg);
     case VERIDENT:
Nur in net-snmp-5.4.3~dfsg/agent/mibgroup/ucd-snmp: versioninfo.c~.
diff -aur net-snmp-5.4.3~dfsg.harden/perl/agent/agent.xs net-snmp-5.4.3~dfsg/perl/agent/agent.xs
--- net-snmp-5.4.3~dfsg.harden/perl/agent/agent.xs	2010-05-11 19:26:56.000000000 +0200
+++ net-snmp-5.4.3~dfsg/perl/agent/agent.xs	2012-01-26 20:14:42.000000000 +0100
@@ -489,7 +489,7 @@
     CODE:
     {
         stringptr = SvPV(value, stringlen);
-        snmp_log(LOG_ERR, stringptr );
+        snmp_log(LOG_ERR, "%s", stringptr );
     }
 
 
Nur in net-snmp-5.4.3~dfsg/perl/agent: agent.xs~.
diff -aur net-snmp-5.4.3~dfsg.harden/perl/SNMP/SNMP.xs net-snmp-5.4.3~dfsg/perl/SNMP/SNMP.xs
--- net-snmp-5.4.3~dfsg.harden/perl/SNMP/SNMP.xs	2009-12-05 18:42:24.000000000 +0100
+++ net-snmp-5.4.3~dfsg/perl/SNMP/SNMP.xs	2012-01-26 20:15:55.000000000 +0100
@@ -3987,7 +3987,7 @@
 	   if (context->req_oids == NULL) {
 	      sprintf(str_buf, "Newz(req_oids) failed (%s)", strerror(errno));
 	      if (verbose)
-	         warn(str_buf);
+	         warn("%s", str_buf);
 	      sv_setpv(*err_str_svp, str_buf);
 	      sv_setiv(*err_num_svp, SNMPERR_MALLOC);
 	      goto err;
Nur in net-snmp-5.4.3~dfsg/perl/SNMP: SNMP.xs~.

Reply via email to