diff options
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r-- | other/DHT_bootstrap.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 9d94fecc..8942c237 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -41,12 +41,14 @@ | |||
41 | 41 | ||
42 | #define PORT 33445 | 42 | #define PORT 33445 |
43 | 43 | ||
44 | //TODO: rewrite | ||
44 | unsigned char * hex_string_to_bin(char hex_string[]) | 45 | unsigned char * hex_string_to_bin(char hex_string[]) |
45 | { | 46 | { |
46 | unsigned char * val = malloc(strlen(hex_string)); | 47 | size_t len = strlen(hex_string); |
48 | unsigned char * val = malloc(len); | ||
47 | char * pos = hex_string; | 49 | char * pos = hex_string; |
48 | int i=0; | 50 | int i=0; |
49 | while(i < strlen(hex_string)) | 51 | while(i < len) |
50 | { | 52 | { |
51 | sscanf(pos,"%2hhx",&val[i]); | 53 | sscanf(pos,"%2hhx",&val[i]); |
52 | pos+=2; | 54 | pos+=2; |
@@ -139,4 +141,4 @@ int main(int argc, char *argv[]) | |||
139 | } | 141 | } |
140 | shutdown_networking(); | 142 | shutdown_networking(); |
141 | return 0; | 143 | return 0; |
142 | } \ No newline at end of file | 144 | } |