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
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127831

View File

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