summaryrefslogtreecommitdiff
path: root/testing/DHT_cryptosendfiletest.c
diff options
context:
space:
mode:
authorKonstantin Kowalski <kostyakow42@gmail.com>2013-07-26 16:16:58 -0400
committerKonstantin Kowalski <kostyakow42@gmail.com>2013-07-26 16:16:58 -0400
commita1b93c397c8776e1bb07e3e01110d0ee5b9d31b9 (patch)
tree2b0c2d136f0e06b2daa50ade33b046b52bc5655d /testing/DHT_cryptosendfiletest.c
parent2bbffc9ca02be91ce4e5fa766bffef6241f1b303 (diff)
took out several strlen() calls out of the loop; replaced int's with size_t where needed
Diffstat (limited to 'testing/DHT_cryptosendfiletest.c')
-rw-r--r--testing/DHT_cryptosendfiletest.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/testing/DHT_cryptosendfiletest.c b/testing/DHT_cryptosendfiletest.c
index b06ddea5..5c3a0256 100644
--- a/testing/DHT_cryptosendfiletest.c
+++ b/testing/DHT_cryptosendfiletest.c
@@ -60,14 +60,15 @@ void printip(IP_Port ip_port)
60 printf("\nIP: %u.%u.%u.%u Port: %u\n",ip_port.ip.c[0],ip_port.ip.c[1],ip_port.ip.c[2],ip_port.ip.c[3],ntohs(ip_port.port)); 60 printf("\nIP: %u.%u.%u.%u Port: %u\n",ip_port.ip.c[0],ip_port.ip.c[1],ip_port.ip.c[2],ip_port.ip.c[3],ntohs(ip_port.port));
61} 61}
62 62
63/* horrible function from one of my first C programs. 63//TODO: rewrite
64 *only here because I was too lazy to write a proper one. */
65unsigned char * hex_string_to_bin(char hex_string[]) 64unsigned char * hex_string_to_bin(char hex_string[])
66{ 65{
67 unsigned char * val = malloc(strlen(hex_string)); 66 size_t len = strlen(hex_string);
67 unsigned char * val = malloc(len);
68 char * pos = hex_string; 68 char * pos = hex_string;
69 int i=0; 69 int i=0;
70 while(i < strlen(hex_string)) { 70 while(i < len)
71 {
71 sscanf(pos,"%2hhx",&val[i]); 72 sscanf(pos,"%2hhx",&val[i]);
72 pos+=2; 73 pos+=2;
73 i++; 74 i++;
@@ -239,4 +240,4 @@ int main(int argc, char *argv[])
239 240
240 shutdown_networking(); 241 shutdown_networking();
241 return 0; 242 return 0;
242} \ No newline at end of file 243}