diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-11-22 04:12:49 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-11-22 04:12:49 +0000 |
commit | f34a9f0a9d06ba7a8b2ff945df3a26db7970c69b (patch) | |
tree | d57205672d49f3cdb33f1fc9a1a8f910adf8c9f9 /sbin/ifconfig/ifconfig.c | |
parent | 04e705a232d9b6abc44accfde7b9a33fe3e19510 (diff) |
Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index a682ee80571..afcf560e8c7 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.278 2013/11/21 17:24:34 millert Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.279 2013/11/22 04:12:47 deraadt Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -800,7 +800,7 @@ getinfo(struct ifreq *ifr, int create) getsock(af); if (s < 0) err(1, "socket"); - if (!isdigit(name[strlen(name) - 1])) + if (!isdigit((unsigned char)name[strlen(name) - 1])) return (-1); /* ignore groups here */ if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) < 0) { int oerrno = errno; @@ -939,7 +939,8 @@ printif(char *ifname, int ifaliases) if ((oname = strdup(ifname)) == NULL) err(1, "strdup"); nlen = strlen(oname); - if (nlen && !isdigit(oname[nlen - 1])) /* is it a group? */ + /* is it a group? */ + if (nlen && !isdigit((unsigned char)oname[nlen - 1])) if (printgroup(oname, ifaliases) != -1) { free(oname); return; @@ -952,14 +953,14 @@ printif(char *ifname, int ifaliases) namep = NULL; for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (oname) { - if (nlen && isdigit(oname[nlen - 1])) { + if (nlen && isdigit((unsigned char)oname[nlen - 1])) { /* must have exact match */ if (strcmp(oname, ifa->ifa_name) != 0) continue; } else { /* partial match OK if it ends w/ digit */ if (strncmp(oname, ifa->ifa_name, nlen) != 0 || - !isdigit(ifa->ifa_name[nlen])) + !isdigit((unsigned char)ifa->ifa_name[nlen])) continue; } } @@ -1376,7 +1377,8 @@ setifgroup(const char *group_name, int dummy) memset(&ifgr, 0, sizeof(ifgr)); strlcpy(ifgr.ifgr_name, name, IFNAMSIZ); - if (group_name[0] && isdigit(group_name[strlen(group_name) - 1])) + if (group_name[0] && + isdigit((unsigned char)group_name[strlen(group_name) - 1])) errx(1, "setifgroup: group names may not end in a digit"); if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ) @@ -1396,7 +1398,8 @@ unsetifgroup(const char *group_name, int dummy) memset(&ifgr, 0, sizeof(ifgr)); strlcpy(ifgr.ifgr_name, name, IFNAMSIZ); - if (group_name[0] && isdigit(group_name[strlen(group_name) - 1])) + if (group_name[0] && + isdigit((unsigned char)group_name[strlen(group_name) - 1])) errx(1, "unsetifgroup: group names may not end in a digit"); if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ) @@ -1556,7 +1559,7 @@ setifnwkey(const char *val, int d) goto set_nwkey; } else { set_nwkey: - if (isdigit(val[0]) && val[1] == ':') { + if (isdigit((unsigned char)val[0]) && val[1] == ':') { /* specifying a full set of four keys */ nwkey.i_defkid = val[0] - '0'; val += 2; @@ -2045,7 +2048,7 @@ ieee80211_status(void) /* check extra ambiguity with keywords */ if (!nwkey_verbose) { if (nwkey.i_key[0].i_keylen >= 2 && - isdigit(nwkey.i_key[0].i_keydat[0]) && + isdigit((unsigned char)nwkey.i_key[0].i_keydat[0]) && nwkey.i_key[0].i_keydat[1] == ':') nwkey_verbose = 1; else if (nwkey.i_key[0].i_keylen >= 7 && @@ -2461,7 +2464,7 @@ settimeslot(const char *val, int d) #define RANGE_CHANNEL 0x2 #define ALL_CHANNELS 0xFFFFFFFF unsigned long ts_map = 0; - char *ptr = (char*)val; + char *ptr = (char *)val; int ts_flag = 0; int ts = 0, ts_start = 0; @@ -2469,7 +2472,7 @@ settimeslot(const char *val, int d) ts_map = ALL_CHANNELS; } else { while (*ptr != '\0') { - if (isdigit(*ptr)) { + if (isdigit((unsigned char)*ptr)) { ts = strtoul(ptr, &ptr, 10); ts_flag |= SINGLE_CHANNEL; } else { |