When looking for key files, we could use isdigit rather than checking
if the character is within the range [0-9].
Use (unsigned char) cast to ensure the value is representable in the
unsigned char type (as suggested by the isdigit manpage).
Change " & 0xff" occurrences to the recommended (unsigned char) type
cast.
(cherry picked from commit
1998ad6c776a9c17c27788b17765dee90d9e25df)
return (false);
}
while (*s != '\0') {
- if (!isdigit((*s) & 0xff)) {
+ if (!isdigit((unsigned char)(*s))) {
return (false);
}
s++;
/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
alg = 0;
for (i = len + 1 + 1; i < dir.entry.length; i++) {
- if (dir.entry.name[i] < '0' || dir.entry.name[i] > '9')
- {
+ if (!isdigit((unsigned char)dir.entry.name[i])) {
break;
}
alg *= 10;
}
for (i++; i < dir.entry.length; i++) {
- if (dir.entry.name[i] < '0' || dir.entry.name[i] > '9')
- {
+ if (!isdigit((unsigned char)dir.entry.name[i])) {
break;
-
- /*
- * Did we not read exactly 5 more digits?
- * Did we overflow?
- * Did we correctly terminate?
- */
}
}
POST(state);
/* FALLTHROUGH */
case ft_escape:
- if (!isdigit(c & 0xff)) {
+ if (!isdigit((unsigned char)c)) {
if (count >= 63) {
return (DNS_R_LABELTOOLONG);
}
state = ft_escdecimal;
/* FALLTHROUGH */
case ft_escdecimal:
- if (!isdigit(c & 0xff)) {
+ if (!isdigit((unsigned char)c)) {
return (DNS_R_BADESCAPE);
}
value *= 10;
char buffer[NUMBERSIZE];
int v;
- if (!isdigit(source->base[0] & 0xff) || source->length > NUMBERSIZE - 1)
- {
+ if (!isdigit((unsigned char)source->base[0]) ||
+ source->length > NUMBERSIZE - 1) {
return (ISC_R_BADNUMBER);
}
RETTOK(DNS_R_SYNTAX);
}
for (i = 0; i < token.value.as_textregion.length; i++) {
- if (!isdigit(token.value.as_textregion.base[i] & 0xff)) {
+ if (!isdigit((unsigned char)token.value.as_textregion.base[i]))
+ {
RETTOK(ISC_R_RANGE);
}
}
}
for (i = 0; i < x25->x25_len; i++) {
- if (!isdigit(x25->x25[i] & 0xff)) {
+ if (!isdigit((unsigned char)x25->x25[i])) {
return (ISC_R_RANGE);
}
}
lastwasperiod = true;
continue;
}
- if ((sr->base[0] < '0') || (sr->base[0] > '9')) {
+ if (!isdigit((unsigned char)sr->base[0])) {
RETTOK(DNS_R_SYNTAX);
}
RETERR(mem_tobuffer(target, sr->base, 1));
if (region.base[0] == 1) {
unsigned int i;
for (i = 1; i < region.length; i++) {
- if (region.base[i] < '0' || region.base[i] > '9') {
+ if (!isdigit((unsigned char)region.base[i])) {
return (DNS_R_FORMERR);
}
}
/* The limit also determines the number of valid digits. */
int rulim = ulim;
- if (**buf < '0' || **buf > '9') {
+ if (!isdigit((unsigned char)**buf)) {
return (0);
}
*/
p = x;
while (*p != '\0') {
- if (isdigit(*p & 0xff)) {
+ if (isdigit((unsigned char)*p)) {
*p = 'a';
} else if (*p != 'z') {
++*p;
*/
p = x;
while (*p != '\0') {
- if (isdigit(*p & 0xff)) {
+ if (isdigit((unsigned char)*p)) {
*p = 'a';
} else if (*p != 'z') {
++*p;
if (*trv == 'z') {
*trv++ = 'a';
} else {
- if (isdigit(*trv)) {
+ if (isdigit((unsigned char)*trv)) {
*trv = 'a';
} else {
++*trv;
/*! \file */
+#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
int i;
for (i = 0; i < 5; i++) {
- if (ndata[i] < '0' || ndata[i] > '9') {
+ if (!isdigit((unsigned char)ndata[i])) {
return (false);
}
v *= 10;