diff options
Diffstat (limited to 'testing/misc_tools.c')
-rw-r--r-- | testing/misc_tools.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/testing/misc_tools.c b/testing/misc_tools.c index 34d64bf4..dbaa8b3b 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c | |||
@@ -25,19 +25,16 @@ | |||
25 | 25 | ||
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | #include <stdio.h> //for sscanf | 28 | #include <stdio.h> /* for sscanf */ |
29 | 29 | ||
30 | //TODO: rewrite | 30 | /* TODO: rewrite */ |
31 | unsigned char * hex_string_to_bin(char hex_string[]) | 31 | unsigned char * hex_string_to_bin(char hex_string[]) |
32 | { | 32 | { |
33 | size_t len = strlen(hex_string); | 33 | size_t len = strlen(hex_string); |
34 | unsigned char *val = malloc(len); | 34 | unsigned char *val = malloc(len); |
35 | char *pos = hex_string; | 35 | char *pos = hex_string; |
36 | int i=0; | 36 | int i; |
37 | while(i < len) { | 37 | for(i = 0; i < len; ++i, pos+=2) |
38 | sscanf(pos,"%2hhx",&val[i]); | 38 | sscanf(pos,"%2hhx",&val[i]); |
39 | pos+=2; | ||
40 | i++; | ||
41 | } | ||
42 | return val; | 39 | return val; |
43 | } \ No newline at end of file | 40 | } |