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

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


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

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

commit 99c2e1081a41ed8070c18b959cb46f3d0772d2b3
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 005ac91..ce17929 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,9 @@ dpkg (1.17.27) UNRELEASED; urgency=medium
     - Set PERL5LIB globally for the test suite to the local modules directory,
       to avoid using the system modules. Regression introduced in dpkg 1.17.8.
       Reported by Jérémy Bobbio <lunar at debian.org>. Closes: #801329
+    - 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>.
 
   [ Updated scripts translations ]
   * German (Helge Kreutzmann). (Various fixes)
diff --git a/lib/compat/strsignal.c b/lib/compat/strsignal.c
index 265feb4..a5d6d53 100644
--- a/lib/compat/strsignal.c
+++ b/lib/compat/strsignal.c
@@ -54,7 +54,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
 
@@ -63,7 +68,7 @@ strsignal(int s)
 {
 	static char buf[100];
 
-	if (s > 0 && s < (int)(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