On 11/23/12 02:17, Philip Guenther wrote: > On Thu, Nov 22, 2012 at 5:28 PM, Alexander Hall <alexan...@beard.se> wrote: >> The corresponding part in yubikey_hex_decode is for consistency and, >> IMO, sanity, allowing mixed case hex strings, e.g. /var/db/yubikey/*. >> >> Comments? OK? (Don't mess with the from-upstream-derived yubikey.c?) > ... >> - if ((p1 = strchr(hex_trans, *src)) == NULL) >> + if ((p1 = strchr(hex_trans, tolower(*src))) == NULL) > > The argument to tolower() must be a value in the range [EOF, > 0..UCHAR_MAX]. When taking characters from a char * string, you need > to cast the value to (unsigned char), ala > tolower((unsigned char)*src) > > > Philip Guenther >
Ok... Is this documented somewhere or just common knowledge? New diff follows, with missing include added too. OK? /Alexander Index: yubikey.c =================================================================== RCS file: /data/openbsd/cvs/src/libexec/login_yubikey/yubikey.c,v retrieving revision 1.2 diff -u -p -r1.2 yubikey.c --- yubikey.c 31 Jan 2012 16:58:38 -0000 1.2 +++ yubikey.c 23 Nov 2012 15:35:29 -0000 @@ -32,6 +32,8 @@ * */ +#include <ctype.h> + #include "yubikey.h" static const uint8_t RC[] = { @@ -252,7 +254,8 @@ yubikey_hex_decode(char *dst, const char char *p1; for (; *src && dstSize > 0; src++) { - if ((p1 = strchr(hex_trans, *src)) == NULL) + p1 = strchr(hex_trans, tolower((unsigned char)*src)); + if (p1 == NULL) b = 0; else b = (char)(p1 - hex_trans); @@ -278,7 +281,8 @@ yubikey_modhex_decode(char *dst, const c char *p1; for (; *src && dstSize > 0; src++) { - if ((p1 = strchr(modhex_trans, *src)) == NULL) + p1 = strchr(modhex_trans, tolower((unsigned char)*src)); + if (p1 == NULL) b = 0; else b = (char)(p1 - modhex_trans);