[Reproducible-commits] [dpkg] 08/10: libcompat: Try to use NSIG when sys_siglist is defined

Holger Levsen holger at layer-acht.org
Tue May 3 08:44:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to annotated tag 1.16.18
in repository dpkg.

commit 12567fa7277e3a0f8ac051827d08e5047bebdb5a
Author: Guillem Jover <guillem at debian.org>
Date:   Wed Jul 29 19:19:18 2015 +0200

    libcompat: Try to use NSIG when sys_siglist is defined
    
    We cannot compute the size of the array with sizeof when the only thing
    we have is an extern declaration. Try to use NSIG, and fallback to 32
    items in case it is not defined.
    
    Prompted-by: Igor Pashev <pashev.igor at gmail.com>
---
 debian/changelog       | 3 +++
 lib/compat/strsignal.c | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 4b6381b..d36dcd1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,9 @@ dpkg (1.16.18) UNRELEASED; urgency=medium
   * Fix physical file offset comparison in dpkg. Closes: #808912
     Thanks to Yuri Gribov <tetra2005 at gmail.com>.
   * Do not accept empty field names in dpkg. Closes: #769111
+  * When sys_siglist is defined in the system, try to use NSIG as we cannot
+    compute the array size with sizeof(). If NSIG is missing fallback to 32
+    items. Prompted by Igor Pashev <pashev.igor at gmail.com>.
 
  -- Guillem Jover <guillem at debian.org>  Sat, 19 Mar 2016 19:13:34 +0100
 
diff --git a/lib/compat/strsignal.c b/lib/compat/strsignal.c
index 92fad03..7ff23e2 100644
--- a/lib/compat/strsignal.c
+++ b/lib/compat/strsignal.c
@@ -52,7 +52,12 @@ const char *const sys_siglist[] = {
 	"SIGTTIN",	/* 21 */
 	"SIGTTOU",	/* 22 */
 };
+# define COMPAT_NSIGLIST (int)(sizeof(sys_siglist) / sizeof(sys_siglist[0]))
 #else
+# ifndef NSIG
+#  define NSIG 32
+# endif
+# define COMPAT_NSIGLIST NSIG
 extern const char *const sys_siglist[];
 #endif
 
@@ -61,7 +66,7 @@ strsignal(int s)
 {
 	static char buf[100];
 
-	if (s > 0 && s < sizeof(sys_siglist) / sizeof(sys_siglist[0]))
+	if (s > 0 && s < COMPAT_NSIGLIST)
 		return sys_siglist[s];
 
 	sprintf(buf, _("Unknown signal %d"), s);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list