Without this fix, the output to the buffer would be limited to maxlen/2 bytes
instead of maxlen. It is obvious from the implementation that the latter
behavior is the expected one, so the function has been altered to reflect that.
uint8_t * dst = buffer;
int ls = 0;
uint8_t b = 0;
- while (*src && maxlen--) {
+ while (*src && maxlen) {
char c = *src++;
switch (c) {
case 'a' ... 'f': b = (b << 4) | (c - 'a' + 0xa); break;
}
if (ls & 1) {
*dst++ = b; b = 0;
+ maxlen--;
}
ls++;
}