1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-22 06:09:01 +00:00

Updated uses of the ctype function to support explict casting of the arguments

to (int)(unsigned char).
This commit is contained in:
josh
2009-08-06 15:10:00 +00:00
parent 990db60861
commit df71e36084
14 changed files with 73 additions and 72 deletions

View File

@@ -156,18 +156,18 @@ static void mac_prefix_init() {
while(fgets(line, sizeof(line), fp)) {
lineno++;
if (*line == '#') continue;
if (!isxdigit(*line)) {
if (!isxdigit((int) (unsigned char) *line)) {
error("Parse error one line #%d of %s. Giving up parsing.", lineno, filename);
break;
}
/* First grab the prefix */
pfx = strtol(line, &endptr, 16);
if (!endptr || !isspace(*endptr)) {
if (!endptr || !isspace((int) (unsigned char) *endptr)) {
error("Parse error one line #%d of %s. Giving up parsing.", lineno, filename);
break;
}
/* Now grab the vendor */
while(*endptr && isspace(*endptr)) endptr++;
while(*endptr && isspace((int) (unsigned char) *endptr)) endptr++;
assert(*endptr);
p = endptr;
while(*endptr && *endptr != '\n' && *endptr != '\r') endptr++;

View File

@@ -297,7 +297,7 @@ void Target::setHostName(char *name) {
while (*p) {
// I think only a-z A-Z 0-9 . and - are allowed, but I'll be a little more
// generous.
if (!isalnum(*p) && !strchr(".-+=:_~*", *p)) {
if (!isalnum((int) (unsigned char) *p) && !strchr(".-+=:_~*", *p)) {
log_write(LOG_STDOUT, "Illegal character(s) in hostname -- replacing with '*'\n");
*p = '*';
}

View File

@@ -185,7 +185,7 @@ int TargetGroup::parse_expr(const char * const target_expr, int af) {
*s = '\0'; /* Make sure target_net is terminated before the /## */
s++; /* Point s at the netmask */
if (!isdigit(*s)) {
if (!isdigit((int) (unsigned char) *s)) {
error("Illegal netmask value, must be /0 - /32 . Assuming /32 (one host)");
netmask = 32;
} else {
@@ -199,7 +199,8 @@ int TargetGroup::parse_expr(const char * const target_expr, int af) {
} else
netmask = 32;
for(i=0; *(hostexp + i); i++)
if (isupper((int) *(hostexp +i)) || islower((int) *(hostexp +i))) {
if (isupper((int) (unsigned char) *(hostexp +i)) ||
islower((int) (unsigned char) *(hostexp +i))) {
namedhost = 1;
break;
}
@@ -251,7 +252,7 @@ int TargetGroup::parse_expr(const char * const target_expr, int af) {
*r = '\0';
addy[i] = r + 1;
}
else if (*r != '*' && *r != ',' && *r != '-' && !isdigit((int)*r))
else if (*r != '*' && *r != ',' && *r != '-' && !isdigit((int) (unsigned char) *r))
fatal("Invalid character in host specification. Note in particular that square brackets [] are no longer allowed. They were redundant and can simply be removed.");
*r++;
}

22
nmap.cc
View File

@@ -130,7 +130,7 @@ static int parse_scanflags(char *arg) {
int flagval = 0;
char *end = NULL;
if (isdigit(arg[0])) {
if (isdigit((int) (unsigned char) arg[0])) {
flagval = strtol(arg, &end, 0);
if (*end || flagval < 0 || flagval > 255) return -1;
} else {
@@ -1461,7 +1461,7 @@ int nmap_main(int argc, char *argv[]) {
const char *p = spoofmac;
while(*p) {
if (*p == ':') p++;
if (isxdigit(*p) && isxdigit(*(p+1))) {
if (isxdigit((int) (unsigned char) *p) && isxdigit((int) (unsigned char) *(p+1))) {
if (pos >= 6) fatal("Bogus --spoof-mac value encountered (%s) -- only up to 6 bytes permitted", spoofmac);
tmphex[0] = *p; tmphex[1] = *(p+1); tmphex[2] = '\0';
mac_data[pos] = (u8) strtol(tmphex, NULL, 16);
@@ -2055,7 +2055,7 @@ int gather_logfile_resumption_state(char *fname, int *myargc, char ***myargv) {
if ((p = strstr(filestr, " as: ")))
p += 5;
else fatal("Unable to parse supposed log file %s. Are you sure this is an Nmap output file?", fname);
while(*p && !isspace((int) *p))
while(*p && !isspace((int) (unsigned char) *p))
p++;
if (!*p) fatal("Unable to parse supposed log file %s. Sorry", fname);
p++; /* Skip the space between program name and first arg */
@@ -2106,7 +2106,7 @@ int gather_logfile_resumption_state(char *fname, int *myargc, char ***myargv) {
if (q) {
while((q = strstr(q, "\nAll "))) {
q+= 5;
while(isdigit(*q)) q++;
while(isdigit((int) (unsigned char) *q)) q++;
if (strncmp(q, " scanned ports on", 17) == 0)
found = q;
}
@@ -2355,7 +2355,7 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_
current_range = origexpr;
do {
while(isspace((int) *current_range))
while(isspace((int) (unsigned char) *current_range))
current_range++; /* I don't know why I should allow spaces here, but I will */
if (change_range_type) {
@@ -2406,7 +2406,7 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_
else
rangestart = 1;
}
else if (isdigit((int) *current_range)) {
else if (isdigit((int) (unsigned char) *current_range)) {
rangestart = strtol(current_range, &endptr, 10);
if (range_type & SCAN_PROTOCOLS) {
if (rangestart < 0 || rangestart > 255)
@@ -2416,11 +2416,11 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_
fatal("Ports to be scanned must be between 0 and 65535 inclusive");
}
current_range = endptr;
while(isspace((int) *current_range)) current_range++;
} else if (islower((int) *current_range) || *current_range == '*' || *current_range == '?') {
while(isspace((int) (unsigned char) *current_range)) current_range++;
} else if (islower((int) (unsigned char) *current_range) || *current_range == '*' || *current_range == '?') {
i = 0;
while (*current_range && !isspace((int)*current_range) && *current_range != ',' && *current_range != ']') {
while (*current_range && !isspace((int) (unsigned char) *current_range) && *current_range != ',' && *current_range != ']') {
servmask[i++] = *(current_range++);
if (i >= ((int)sizeof(servmask)-1))
fatal("A service mask in the port/protocol specification is either malformed or too long");
@@ -2452,7 +2452,7 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_
rangeend = 255;
else
rangeend = 65535;
} else if (isdigit((int) *current_range)) {
} else if (isdigit((int) (unsigned char) *current_range)) {
rangeend = strtol(current_range, &endptr, 10);
if (range_type & SCAN_PROTOCOLS) {
if (rangeend < 0 || rangeend > 255)
@@ -2507,7 +2507,7 @@ static void getpts_aux(const char *origexpr, int nested, u8 *porttbl, int range_
}
/* Find the next range */
while(isspace((int) *current_range)) current_range++;
while(isspace((int) (unsigned char) *current_range)) current_range++;
if (*current_range == ']') {
if (!nested) fatal("Unexpected ] character in port/protocol specification");

View File

@@ -583,7 +583,7 @@ static u32 parse_inaddr_arpa(unsigned char *buf, int maxlen) {
maxlen -= buf[0] + 1;
if (maxlen <= 0) return 0;
for (j=1; j<=buf[0]; j++) if (!isdigit(buf[j])) return 0;
for (j=1; j<=buf[0]; j++) if (!isdigit((int) buf[j])) return 0;
ip |= atoi((char *) buf+1) << (8*i);
buf += buf[0] + 1;

View File

@@ -155,7 +155,7 @@ static void rpc_services_init() {
ri.num_alloc *= 3;
}
while(*p && *p != '#' && !isalnum((int) *p)) p++;
while(*p && *p != '#' && !isalnum((int) (unsigned char) *p)) p++;
if (!*p || *p == '#') continue;
@@ -167,7 +167,7 @@ static void rpc_services_init() {
ri.names[ri.num_used] = cp_strdup(p);
p = tmpptr + 1;
while(*p && !isdigit((int) *p)) p++;
while(*p && !isdigit((int) (unsigned char) *p)) p++;
if (!*p)
continue;

View File

@@ -133,10 +133,10 @@ static int l_unpack(lua_State *L) /** unpack(f,s, [init]) */
{
int c=*f++;
int N=1;
if (isdigit(*f))
if (isdigit((int) (unsigned char) *f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
while (isdigit((int) (unsigned char) *f)) N=10*N+(*f++)-'0';
if (N==0 && c==OP_STRING) { lua_pushliteral(L,""); ++n; }
}
while (N-- && done == 0) switch (c)
@@ -283,10 +283,10 @@ static int l_pack(lua_State *L) /** pack(f,...) */
{
int c=*f++;
int N=1;
if (isdigit(*f))
if (isdigit((int) (unsigned char) *f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
while (isdigit((int) (unsigned char) *f)) N=10*N+(*f++)-'0';
}
while (N--) switch (c)
{
@@ -357,8 +357,8 @@ static int l_pack(lua_State *L) /** pack(f,...) */
int odd = 0;
const char *a = luaL_checklstring(L, i++, &l);
for (ii = 0; ii < l; ii++) {
if (isxdigit(a[ii])) {
if (isdigit(a[ii])) {
if (isxdigit((int) (unsigned char) a[ii])) {
if (isdigit((int) (unsigned char) a[ii])) {
sbyte += a[ii] - '0';
odd++;
} else if (a[ii] >= 'A' && a[ii] <= 'F') {

View File

@@ -201,13 +201,13 @@ static std::string hexify(const unsigned char *str, size_t len)
// If more than 95% of the chars are printable, we escape unprintable chars
for (size_t i = 0; i < len; i++)
if (isprint(str[i]))
if (isprint((int) str[i]))
num++;
if ((double) num / (double) len >= 0.95)
{
for (size_t i = 0; i < len; i++)
{
if (isprint(str[i]) || isspace(str[i]))
if (isprint((int) str[i]) || isspace((int) str[i]))
ret << str[i];
else
ret << std::setw(3) << "\\" << (unsigned int) (unsigned char) str[i];
@@ -225,7 +225,7 @@ static std::string hexify(const unsigned char *str, size_t len)
else
ret << " ";
for (size_t j = i; j < i + 16 && j < len; j++)
ret.put(isgraph(str[j]) ? (unsigned char) str[j] : ' ');
ret.put(isgraph((int) str[j]) ? (unsigned char) str[j] : ' ');
ret << std::endl;
}
return ret.str();

View File

@@ -222,19 +222,19 @@ static int AVal_match(struct AVal *reference, struct AVal *fprint, struct AVal *
if (val == 0 || *endptr) { if (andexp) { testfailed=1; break; } }
else { numtrue++; if (orexp) break; }
}
} else if (*p == '<' && isxdigit((int) p[1])) {
} else if (*p == '<' && isxdigit((int) (unsigned char) p[1])) {
if (!*current_fp->value) { if (andexp) { testfailed=1; break; } }
number = strtol(p + 1, &endptr, 16);
val = strtol(current_fp->value, &endptr, 16);
if (val >= number || *endptr) { if (andexp) { testfailed=1; break; } }
else { numtrue++; if (orexp) break; }
} else if (*p == '>' && isxdigit((int) p[1])) {
} else if (*p == '>' && isxdigit((int) (unsigned char) p[1])) {
if (!*current_fp->value) { if (andexp) { testfailed=1; break; } }
number = strtol(p + 1, &endptr, 16);
val = strtol(current_fp->value, &endptr, 16);
if (val <= number || *endptr) { if (andexp) { testfailed=1; break; } }
else { numtrue++; if (orexp) break; }
} else if (((q1 = strchr(p, '-')) != NULL) && isxdigit((int) p[0]) && isxdigit((int) q1[1])) {
} else if (((q1 = strchr(p, '-')) != NULL) && isxdigit((int) (unsigned char) p[0]) && isxdigit((int) (unsigned char) q1[1])) {
if (!*current_fp->value) { if (andexp) { testfailed=1; break; } }
*q1 = '\0'; number = strtol(p, NULL, 16);
number1 = strtol(q1 + 1, NULL, 16);
@@ -793,9 +793,9 @@ static char *substrstrip(const char *p, const char *q) {
assert(p <= q);
while (isspace(*p))
while (isspace((int) (unsigned char) *p))
p++;
while (q > p && isspace(*(q - 1)))
while (q > p && isspace((int) (unsigned char) *(q - 1)))
q--;
s = (char *) cp_alloc(q - p + 1);
@@ -842,7 +842,7 @@ static void parse_classline(FingerPrint *FP, char *thisline, int lineno,
fatal("Parse error on line %d of fingerprint: %s\n", lineno, thisline);
/* OS generation is handled specially: instead of an empty string it's
supposed to be NULL. */
while (isspace(*begin))
while (isspace((int) (unsigned char) *begin))
begin++;
if (begin < end)
os_class->OS_Generation = substrstrip(begin, end);
@@ -884,7 +884,7 @@ FingerPrint *parse_single_fingerprint(char *fprint_orig) {
if (nextline) *nextline++ = '\0';
/* printf("Preparing to handle next line: %s\n", thisline); */
while(*thisline && isspace((int) *thisline)) thisline++;
while(*thisline && isspace((int) (unsigned char) *thisline)) thisline++;
if (!*thisline) {
fatal("Parse error on line %d of fingerprint: %s", lineno, nextline);
}
@@ -893,11 +893,11 @@ FingerPrint *parse_single_fingerprint(char *fprint_orig) {
/* Ignore a second Fingerprint line if it appears. */
if (FP->OS_name == NULL) {
p = thisline + 12;
while(*p && isspace((int) *p)) p++;
while(*p && isspace((int) (unsigned char) *p)) p++;
q = strchr(p, '\n');
if (!q) q = p + strlen(p);
while(q > p && isspace(*(--q)))
while(q > p && isspace((int) (unsigned char) *(--q)))
;
FP->OS_name = (char *) cp_alloc(q - p + 2);
@@ -1029,12 +1029,12 @@ while(fgets(line, sizeof(line), fp)) {
} else {
DB->prints[numrecords] = current;
p = line + 12;
while(*p && isspace((int) *p)) p++;
while(*p && isspace((int) (unsigned char) *p)) p++;
q = strpbrk(p, "\n#");
if (!p) fatal("Parse error on line %d of fingerprint: %s", lineno, line);
while(isspace(*(--q)))
while(isspace((int) (unsigned char) *(--q)))
;
if (q < p) fatal("Parse error on line %d of fingerprint: %s", lineno, line);

View File

@@ -144,7 +144,7 @@ static void skid_output(char *s)
case 'O': s[i]='0'; break;
case 's':
case 'S':
if (s[i+1] && !isalnum((int) s[i+1]))
if (s[i+1] && !isalnum((int) (unsigned char) s[i+1]))
s[i] = 'z';
else s[i] = '$';
break;

View File

@@ -132,7 +132,7 @@ static int nmap_protocols_init() {
while(fgets(line, sizeof(line), fp)) {
lineno++;
p = line;
while(*p && isspace((int) *p))
while(*p && isspace((int) (unsigned char) *p))
p++;
if (*p == '#')
continue;

View File

@@ -302,7 +302,7 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
isInitialized = true;
deflineno = lineno;
while(isspace(*matchtext)) matchtext++;
while(isspace((int) (unsigned char) *matchtext)) matchtext++;
// first we find whether this is a "soft" or normal match
if (strncmp(matchtext, "softmatch ", 10) == 0) {
@@ -330,7 +330,7 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
// options. ('i' means "case insensitive", 's' means that . matches
// newlines (both are just as in perl)
matchtext = p;
while(isspace(*matchtext)) matchtext++;
while(isspace((int) (unsigned char) *matchtext)) matchtext++;
if (*matchtext == 'm') {
if (!*(matchtext+1))
fatal("%s: parse error on line %d of nmap-service-probes: matchtext must begin with 'm'", __func__, lineno);
@@ -347,7 +347,7 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
matchtext = p + 1; // skip past the delim
// any options?
while(*matchtext && !isspace(*matchtext)) {
while(*matchtext && !isspace((int) (unsigned char) *matchtext)) {
if (*matchtext == 'i')
matchops_ignorecase = true;
else if (*matchtext == 's')
@@ -384,7 +384,7 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
* delimiter character and ... is a template */
while(1) {
while(isspace(*matchtext)) matchtext++;
while(isspace((int) (unsigned char) *matchtext)) matchtext++;
if (*matchtext == '\0' || *matchtext == '\r' || *matchtext == '\n') break;
modechar = *(matchtext++);
@@ -507,7 +507,7 @@ static int getsubstcommandargs(struct substargs *args, char *args_start,
while(*args_start && *args_start != ')') {
// Find the next argument.
while(isspace(*args_start)) args_start++;
while(isspace((int) (unsigned char) *args_start)) args_start++;
if (*args_start == ')')
break;
else if (*args_start == '"') {
@@ -581,7 +581,7 @@ static int substvar(char *tmplvar, char **tmplvarend, char *newstr,
if (*tmplvar != '$') return -1;
tmplvar++;
if (!isdigit(*tmplvar)) {
if (!isdigit((int) (unsigned char) *tmplvar)) {
p = strchr(tmplvar, '(');
if (!p) return -1;
len = p - tmplvar;
@@ -707,7 +707,7 @@ static int dotmplsubst(const u8 *subject, int subjectlen,
}
*dst = '\0';
while (--dst >= newstr) {
if (isspace(*dst) || *dst == ',')
if (isspace((int) (unsigned char) *dst) || *dst == ',')
*dst = '\0';
else break;
}
@@ -734,7 +734,7 @@ static int dotmplsubst(const u8 *subject, int subjectlen,
return -1;
*dst = '\0';
while (--dst >= newstr) {
if (isspace(*dst) || *dst == ',')
if (isspace((int) (unsigned char) *dst) || *dst == ',')
*dst = '\0';
else break;
}
@@ -887,7 +887,7 @@ void ServiceProbe::setProbeDetails(char *pd, int lineno) {
pd += 4;
// Next the service name
if (!isalnum(*pd)) fatal("Parse error on line %d of nmap-service-probes - bad probe name", lineno);
if (!isalnum((int) (unsigned char) *pd)) fatal("Parse error on line %d of nmap-service-probes - bad probe name", lineno);
p = strchr(pd, ' ');
if (!p) fatal("Parse error on line %d of nmap-service-probes - nothing after probe name", lineno);
len = p - pd;
@@ -928,14 +928,14 @@ void ServiceProbe::setPortVector(vector<u16> *portv, const char *portstr,
current_range = portstr;
do {
while(*current_range && isspace(*current_range)) current_range++;
if (isdigit((int) *current_range)) {
while(*current_range && isspace((int) (unsigned char) *current_range)) current_range++;
if (isdigit((int) (unsigned char) *current_range)) {
rangestart = strtol(current_range, &endptr, 10);
if (rangestart < 0 || rangestart > 65535) {
fatal("Parse error on line %d of nmap-service-probes: Ports must be between 0 and 65535 inclusive", lineno);
}
current_range = endptr;
while(isspace((int) *current_range)) current_range++;
while(isspace((int) (unsigned char) *current_range)) current_range++;
} else {
fatal("Parse error on line %d of nmap-service-probes: An example of proper portlist form is \"21-25,53,80\"", lineno);
}
@@ -946,7 +946,7 @@ void ServiceProbe::setPortVector(vector<u16> *portv, const char *portstr,
rangeend = rangestart;
} else if (*current_range == '-') {
current_range++;
if (isdigit((int) *current_range)) {
if (isdigit((int) (unsigned char) *current_range)) {
rangeend = strtol(current_range, &endptr, 10);
if (rangeend < 0 || rangeend > 65535 || rangeend < rangestart) {
fatal("Parse error on line %d of nmap-service-probes: Ports must be between 0 and 65535 inclusive", lineno);
@@ -966,7 +966,7 @@ void ServiceProbe::setPortVector(vector<u16> *portv, const char *portstr,
}
/* Find the next range */
while(isspace((int) *current_range)) current_range++;
while(isspace((int) (unsigned char) *current_range)) current_range++;
if (*current_range && *current_range != ',') {
fatal("Parse error on line %d of nmap-service-probes: An example of proper portlist form is \"21-25,53,80\"", lineno);
}
@@ -1430,7 +1430,7 @@ void ServiceNFO::addToServiceFingerprint(const char *probeName, const u8 *resp,
else if (resp[srcidx] == '\0') {
/* We need to be careful with this, because if it is followed by
an ASCII number, PCRE will treat it differently. */
if (srcidx + 1 >= respused || !isdigit(resp[srcidx + 1]))
if (srcidx + 1 >= respused || !isdigit((int) resp[srcidx + 1]))
addServiceString("\\0", servicewrap);
else addServiceString("\\x00", servicewrap);
} else if (strchr("\\?\"[]().*+$^|", resp[srcidx])) {

View File

@@ -186,7 +186,7 @@ static int nmap_services_init() {
while(fgets(line, sizeof(line), fp)) {
lineno++;
p = line;
while(*p && isspace((int) *p))
while(*p && isspace((int) (unsigned char) *p))
p++;
if (*p == '#')
continue;

View File

@@ -119,7 +119,7 @@ int wildtest(char *wild, char *test) {
if (wild[1] == '\0') return 1;
for(i=0; test[i]!='\0'; i++)
if ((tolower((int)wild[1]) == tolower((int)test[i]) || wild[1] == '?')
if ((tolower((int) (unsigned char) wild[1]) == tolower((int) (unsigned char) test[i]) || wild[1] == '?')
&& wildtest(wild+1, test+i) == 1) return 1;
return 0;
@@ -128,11 +128,11 @@ int wildtest(char *wild, char *test) {
/* --- '?' can't match '\0'. --- */
if (*wild == '?' && *test == '\0') return 0;
if (*wild != '?' && tolower((int)*wild) != tolower((int)*test)) return 0;
if (*wild != '?' && tolower((int) (unsigned char) *wild) != tolower((int) (unsigned char) *test)) return 0;
wild++; test++;
}
if (tolower((int)*wild) == tolower((int)*test)) return 1;
if (tolower((int) (unsigned char) *wild) == tolower((int) (unsigned char) *test)) return 1;
return 0;
}
@@ -392,7 +392,7 @@ int arg_parse(const char *command, char ***argv) {
myargv++;
start = mycommand;
while(start && *start) {
while(*start && isspace((int) *start))
while(*start && isspace((int) (unsigned char) *start))
start++;
if (*start == '"') {
start++;
@@ -404,7 +404,7 @@ int arg_parse(const char *command, char ***argv) {
continue;
} else {
end = start+1;
while(*end && !isspace((int) *end)) {
while(*end && !isspace((int) (unsigned char) *end)) {
end++;
}
}
@@ -446,14 +446,14 @@ void arg_parse_free(char **argv) {
static unsigned char hex2char(unsigned char a, unsigned char b)
{
int val;
if (!isxdigit(a) || !isxdigit(b)) return 0;
a = tolower(a);
b = tolower(b);
if (isdigit(a))
if (!isxdigit((int) a) || !isxdigit((int) b)) return 0;
a = tolower((int) a);
b = tolower((int) b);
if (isdigit((int) a))
val = (a - '0') << 4;
else val = (10 + (a - 'a')) << 4;
if (isdigit(b))
if (isdigit((int) b))
val += (b - '0');
else val += 10 + (b - 'a');
@@ -492,12 +492,12 @@ char *cstring_unescape(char *str, unsigned int *newlen) {
case 'x':
src++;
if (!*src || !*(src + 1)) return NULL;
if (!isxdigit(*src) || !isxdigit(*(src + 1))) return NULL;
if (!isxdigit((int) (unsigned char) *src) || !isxdigit((int) (unsigned char) *(src + 1))) return NULL;
newchar = hex2char(*src, *(src + 1));
src += 2;
break;
default:
if (isalnum(*src))
if (isalnum((int) (unsigned char) *src))
return NULL; // I don't really feel like supporting octals such as \015
// Other characters I'll just copy as is
newchar = *src;
@@ -558,7 +558,7 @@ int parse_ip_options(char *txt, u8 *data, int datalen, int* firsthopoff, int* la
base = 16;
break;
}
if(isxdigit(*c)){
if(isxdigit((int) (unsigned char) *c)){
*d++ = strtol(c, &n, base);
c=n-1;
}else