Browse code

Trimming inpu

Lucian Balaceanu authored on 25/08/2016 13:05:47
Showing 1 changed files
... ...
@@ -28,9 +28,10 @@
28 28
 #include <arpa/inet.h>
29 29
 #include <string.h>
30 30
 #include <unistd.h>
31
+#include "../../dprint.h"
32
+#include "../../trim.h"
31 33
 #include "../../str.h"
32 34
 #include "detailed_ip_type.h"
33
-#include "../../dprint.h"
34 35
 
35 36
 static ip4_node IPv4ranges[IPv4RANGES_SIZE] = {
36 37
         { 0xffffffff,  "BROADCAST",  0xffffffff },  // 255.255.255.255/32
... ...
@@ -91,6 +92,7 @@ int ip6_iptype(str string_ip, char **res)
91 92
   char in6_string[INET6_ADDRSTRLEN];
92 93
   int i;
93 94
 
95
+  trim(&string_ip);
94 96
   if (string_ip.len >= INET6_ADDRSTRLEN)
95 97
         return 0;
96 98
 
... ...
@@ -118,6 +120,7 @@ int ip4_iptype(str string_ip, char **res)
118 120
   char in4_string[INET_ADDRSTRLEN];
119 121
   int i;
120 122
 
123
+  trim(&string_ip);
121 124
   if (string_ip.len >= INET_ADDRSTRLEN)
122 125
       return 0;
123 126