]> git.ipfire.org Git - people/ms/dma.git/commitdiff
Resurrect the build hardening patch and fix a couple of unchecked
authorPeter Pentchev <roam@ringlet.net>
Thu, 3 Jun 2010 07:50:54 +0000 (07:50 +0000)
committerPeter Pentchev <roam@ringlet.net>
Thu, 3 Jun 2010 07:50:54 +0000 (07:50 +0000)
asprintf(3) and vasprintf(3) calls.

changelog
patches/13-hardening.patch [new file with mode: 0644]
patches/series

index 303cc868773eb43e0c0518d7dd02bae7a22ece27..2f6173391cf954a425565bbc48fae44a0e2e057d 100644 (file)
--- a/changelog
+++ b/changelog
@@ -7,6 +7,8 @@ dma (0.0.2009.08.29-1) UNRELEASED; urgency=low
     - remove the 20-parse-recipient patch, implemented upstream in
       a different way
     - remove the 22-openfiles.patch, overtaken by upstream changes
+    - resurrect the 13-hardening patch, correcting a couple of
+      unchecked asprintf(3) and vasprintf(3) invocations
     - add the 26-getprogname patch to use program_invocation_short_name()
       instead of getprogname() on GNU systems
     - add the 27-int-size patch to cast a variable to the correct type
diff --git a/patches/13-hardening.patch b/patches/13-hardening.patch
new file mode 100644 (file)
index 0000000..fbfe6df
--- /dev/null
@@ -0,0 +1,53 @@
+Description: Build hardening: check a few more return values.
+ I'll forward this patch as soon as I catch up with the dma upstream.
+Origin: other: http://svn.ringlet.net/svn/ringlet/mail/dma/
+Forwarded: no
+Author: Peter Pentchev <roam@ringlet.net>
+Last-Update: 2010-06-03
+
+--- a/util.c
++++ b/util.c
+@@ -92,9 +92,9 @@
+               char *sufx;
+               va_start(ap, fmt);
+-              vasprintf(&sufx, fmt, ap);
+-              if (sufx != NULL) {
+-                      asprintf(&tag, "%s[%s]", logident_base, sufx);
++              if (vasprintf(&sufx, fmt, ap) != -1 && sufx != NULL) {
++                      if (asprintf(&tag, "%s[%s]", logident_base, sufx) == -1)
++                              tag = NULL;
+                       free(sufx);
+               }
+               va_end(ap);
+@@ -112,7 +112,8 @@
+       if (fmt != NULL) {
+               va_start(ap, fmt);
+-              vasprintf(&outs, fmt, ap);
++              if (vasprintf(&outs, fmt, ap) == -1)
++                      outs = NULL;
+               va_end(ap);
+       }
+@@ -135,7 +136,8 @@
+       if (fmt != NULL) {
+               va_start(ap, fmt);
+-              vasprintf(&outs, fmt, ap);
++              if (vasprintf(&outs, fmt, ap) == -1)
++                      outs = NULL;
+               va_end(ap);
+       }
+@@ -189,8 +191,8 @@
+               else
+                       free(u);
+       }
+-      asprintf(__DECONST(void *, &username), "%ld", (long)uid);
+-      if (username != NULL)
++      if (asprintf(__DECONST(void *, &username), "%ld", (long)uid) != -1 &&
++          username != NULL)
+               return;
+       username = "unknown-or-invalid-username";
+ }
index 7f47b3183fb6cf6a5b822dd1216a2d7f5d5a693a..7d3d40813824c3e1684117ca0ace4c938b2eaf1e 100644 (file)
@@ -4,6 +4,7 @@
 09-typos.patch
 10-liblockfile.patch
 11-double-bounce.patch
+13-hardening.patch
 17-mailname.patch
 23-dirent-d_type.patch
 24-random-message-id.patch