]> granicus.if.org Git - strace/commitdiff
2003-10-01 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Wed, 1 Oct 2003 07:50:28 +0000 (07:50 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 1 Oct 2003 07:50:28 +0000 (07:50 +0000)
* signal.c [LINUX] (parse_sigset_t): Rewrite to process hex strings
from right to left so we don't have to presume the size.
Fixes RH#105995.  Reported by David Woodhouse <dwmw2@redhat.com>.

signal.c

index 9ced43efa55047b80fa8b55d42246ed8a94db07c..0dbc3e9f20a032494df7e2f0926019e337bcd8f3 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -765,16 +765,24 @@ int verbose;
 static void
 parse_sigset_t (const char *str, sigset_t *set)
 {
+       const char *p;
        unsigned int digit;
        int i;
 
        sigemptyset(set);
 
-       for (i = _NSIG - 4; i >= 0; i -= 4, ++str) {
-               if (*str >= 'a')
-                       digit = (*str - 'a') + 10;
+       p = strchr(str, '\n');
+       if (p == NULL)
+               p = strchr(str, '\0');
+       for (i = 0; p-- > str; i += 4) {
+               if (*p >= '0' && *p <= '9')
+                       digit = *p - '0';
+               else if (*p >= 'a' && *p <= 'f')
+                       digit = *p - 'a';
+               else if (*p >= 'A' && *p <= 'F')
+                       digit = *p - 'A';
                else
-                       digit = *str - '0';
+                       break;
                if (digit & 1)
                        sigaddset(set, i + 1);
                if (digit & 2)