Also, use isascii() to avoid surprises from characters with the 8th bit
set, rather than playing signed vs. unsigned character games.
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
int fd;
char linebuf[512];
int linenum;
- unsigned char *p;
+ char *p;
char name[512]; /* XXX - pick a size */
char *q, *saveq;
struct ifreq ifrflags;
/*
* Skip leading white space.
*/
- while (*p != '\0' && isspace(*p))
+ while (*p != '\0' && isascii(*p) && isspace(*p))
p++;
if (*p == '\0' || *p == '\n')
continue; /* blank line */
* Get the interface name.
*/
q = &name[0];
- while (*p != '\0' && !isspace(*p)) {
+ while (*p != '\0' && isascii(*p) && !isspace(*p)) {
if (*p == ':') {
/*
* This could be the separator between a
* next field.
*/
saveq = q;
- while (isdigit(*p))
+ while (isascii(*p) && isdigit(*p))
*q++ = *p++;
if (*p != ':') {
/*