Fix an off-by-one error in the function used to input the ascii/hex strings.

Be a little bit more helpful in error messages.
This commit is contained in:
Poul-Henning Kamp 2004-04-04 07:28:58 +00:00
parent 69b11e006b
commit d2aeb9ccaa

View File

@ -546,17 +546,20 @@ get_string(const char *val, const char *sep, u_int8_t *buf, int *lenp)
break;
}
if (hexstr) {
if (!isxdigit((u_char)val[0]) ||
!isxdigit((u_char)val[1])) {
if (!isxdigit((u_char)val[0])) {
warnx("bad hexadecimal digits");
return NULL;
}
if (!isxdigit((u_char)val[1])) {
warnx("odd count hexadecimal digits");
return NULL;
}
}
if (p > buf + len) {
if (p >= buf + len) {
if (hexstr)
warnx("hexadecimal digits too long");
else
warnx("strings too long");
warnx("string too long");
return NULL;
}
if (hexstr) {