| 1 |
Avoid undefined behaviour when char is unsigned. |
| 2 |
|
| 3 |
diff -ur psutils-1.23.orig/psselect.c psutils-1.23/psselect.c |
| 4 |
--- psutils-1.23.orig/psselect.c 2014-01-15 20:08:26.000000000 +0100 |
| 5 |
+++ psutils-1.23/psselect.c 2014-06-19 12:56:34.000000000 +0200 |
| 6 |
@@ -43,9 +43,9 @@ |
| 7 |
if(!str) return NULL; |
| 8 |
|
| 9 |
sign = (*str == '_' && ++str) ? -1 : 1; |
| 10 |
- if (isdigit(*str)) { |
| 11 |
+ if (isdigit((unsigned char)*str)) { |
| 12 |
first = sign*atoi(str); |
| 13 |
- while (isdigit(*str)) str++; |
| 14 |
+ while (isdigit((unsigned char)*str)) str++; |
| 15 |
} |
| 16 |
switch (*str) { |
| 17 |
case '\0': |
| 18 |
@@ -62,9 +62,9 @@ |
| 19 |
sign = (*str == '_' && ++str) ? -1 : 1; |
| 20 |
if (!first) |
| 21 |
first = 1; |
| 22 |
- if (isdigit(*str)) { |
| 23 |
+ if (isdigit((unsigned char)*str)) { |
| 24 |
int last = sign*atoi(str); |
| 25 |
- while (isdigit(*str)) str++; |
| 26 |
+ while (isdigit((unsigned char)*str)) str++; |
| 27 |
if (*str == '\0') |
| 28 |
return (makerange(first, last, rp)); |
| 29 |
if (*str == ',') |
| 30 |
diff -ur psutils-1.23.orig/psspec.c psutils-1.23/psspec.c |
| 31 |
--- psutils-1.23.orig/psspec.c 2014-01-15 20:08:26.000000000 +0100 |
| 32 |
+++ psutils-1.23/psspec.c 2014-06-19 12:56:34.000000000 +0200 |
| 33 |
@@ -35,7 +35,7 @@ |
| 34 |
char *s = *sp; |
| 35 |
int num = atoi(s); |
| 36 |
|
| 37 |
- while (isdigit(*s)) |
| 38 |
+ while (isdigit((unsigned char)*s)) |
| 39 |
s++; |
| 40 |
if (*sp == s) argerror(); |
| 41 |
*sp = s; |
| 42 |
@@ -47,7 +47,7 @@ |
| 43 |
char *s = *sp; |
| 44 |
double num = atof(s); |
| 45 |
|
| 46 |
- while (isdigit(*s) || *s == '-' || *s == '.') |
| 47 |
+ while (isdigit((unsigned char)*s) || *s == '-' || *s == '.') |
| 48 |
s++; |
| 49 |
if (*sp == s) argerror(); |
| 50 |
*sp = s; |
| 51 |
diff -ur psutils-1.23.orig/pstops.c psutils-1.23/pstops.c |
| 52 |
--- psutils-1.23.orig/pstops.c 2014-01-15 20:08:26.000000000 +0100 |
| 53 |
+++ psutils-1.23/pstops.c 2014-06-19 12:56:34.000000000 +0200 |
| 54 |
@@ -34,7 +34,7 @@ |
| 55 |
|
| 56 |
head = tail = newspec(); |
| 57 |
while (*str) { |
| 58 |
- if (isdigit(*str)) { |
| 59 |
+ if (isdigit((unsigned char)*str)) { |
| 60 |
num = parseint(&str); |
| 61 |
} else { |
| 62 |
switch (*str++) { |
| 63 |
diff -ur psutils-1.23.orig/psutil.c psutils-1.23/psutil.c |
| 64 |
--- psutils-1.23.orig/psutil.c 2014-01-16 08:57:40.000000000 +0100 |
| 65 |
+++ psutils-1.23/psutil.c 2014-06-19 12:56:34.000000000 +0200 |
| 66 |
@@ -258,7 +258,7 @@ |
| 67 |
if (fgets(buffer, BUFSIZ, infile) != NULL && |
| 68 |
iscomment(buffer, "%%Page:")) { |
| 69 |
char *start, *end; |
| 70 |
- for (start = buffer+7; isspace(*start); start++); |
| 71 |
+ for (start = buffer+7; isspace((unsigned char)*start); start++); |
| 72 |
if (*start == '(') { |
| 73 |
int paren = 1; |
| 74 |
for (end = start+1; paren > 0; end++) |
| 75 |
@@ -275,7 +275,7 @@ |
| 76 |
break; |
| 77 |
} |
| 78 |
} else |
| 79 |
- for (end = start; !isspace(*end); end++); |
| 80 |
+ for (end = start; !isspace((unsigned char)*end); end++); |
| 81 |
strncpy(pagelabel, start, end-start); |
| 82 |
pagelabel[end-start] = '\0'; |
| 83 |
pageno = atoi(end); |