| 37 | }; |
| 38 | |
| 39 | int hex_to_bytes(unsigned char *binary, const char *hex, size_t len) |
| 40 | { |
| 41 | for (; len; len--, hex += 2) { |
| 42 | unsigned int val = (hexval(hex[0]) << 4) | hexval(hex[1]); |
| 43 | |
| 44 | if (val & ~0xff) |
| 45 | return -1; |
| 46 | *binary++ = val; |
| 47 | } |
| 48 | return 0; |
| 49 | } |
no test coverage detected