add odd numbers for hex_decode

This commit is contained in:
2024-03-28 18:32:59 -07:00
parent cf6d3ce892
commit c795f607ef
2 changed files with 16 additions and 1 deletions

View File

@ -209,7 +209,12 @@ unsigned char *hex_decode(const char *orig, size_t *sz) {
}
char *buf = malloc(sizeof(char) * buf_sz);
strcpy(buf, orig);
if (strlen(orig) % 2 != 0) {
strcpy(buf + 1, orig);
buf[0] = '0';
} else {
strcpy(buf, orig);
}
buf[buf_sz - 1] = '\0';
*sz = buf_sz / 2;