check for digits in case of BCD encoded PIN

This commit is contained in:
Frank Morgner 2017-09-20 10:13:26 +02:00
parent 60e8db4c22
commit 4f189a5174
1 changed files with 3 additions and 0 deletions

View File

@ -258,6 +258,9 @@ int sc_build_pin(u8 *buf, size_t buflen, struct sc_pin_cmd_pin *pin, int pad)
if (pin_len > 2 * buflen)
return SC_ERROR_BUFFER_TOO_SMALL;
for (i = j = 0; j < pin_len; j++) {
if (!isdigit(pin->data[j])) {
return SC_ERROR_INVALID_DATA;
}
buf[i] <<= 4;
buf[i] |= pin->data[j] & 0xf;
if (j & 1)