diff options
-rw-r--r-- | src/transport/plugin_transport_http_common.c | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index a7a39baec..f13884507 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c | |||
@@ -51,9 +51,23 @@ http_common_plugin_address_pretty_printer (void *cls, const char *type, | |||
51 | asc, void *asc_cls) | 51 | asc, void *asc_cls) |
52 | { | 52 | { |
53 | const char *saddr = (const char *) addr; | 53 | const char *saddr = (const char *) addr; |
54 | GNUNET_assert (NULL != saddr); | 54 | if (NULL == saddr) |
55 | GNUNET_assert (0 < addrlen); | 55 | { |
56 | GNUNET_assert (saddr[addrlen-1] == '\0'); | 56 | asc (asc_cls, NULL); |
57 | return; | ||
58 | } | ||
59 | if (0 >= addrlen) | ||
60 | if (NULL == saddr) | ||
61 | { | ||
62 | asc (asc_cls, NULL); | ||
63 | return; | ||
64 | } | ||
65 | if (saddr[addrlen-1] != '\0') | ||
66 | if (NULL == saddr) | ||
67 | { | ||
68 | asc (asc_cls, NULL); | ||
69 | return; | ||
70 | } | ||
57 | asc (asc_cls, saddr); | 71 | asc (asc_cls, saddr); |
58 | } | 72 | } |
59 | 73 | ||
@@ -73,9 +87,12 @@ const char * | |||
73 | http_common_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | 87 | http_common_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) |
74 | { | 88 | { |
75 | const char *saddr = (const char *) addr; | 89 | const char *saddr = (const char *) addr; |
76 | GNUNET_assert (NULL != saddr); | 90 | if (NULL == saddr) |
77 | GNUNET_assert (0 < addrlen); | 91 | return NULL; |
78 | GNUNET_assert (saddr[addrlen-1] == '\0'); | 92 | if (0 >= addrlen) |
93 | return NULL; | ||
94 | if (saddr[addrlen-1] != '\0') | ||
95 | return NULL; | ||
79 | return saddr; | 96 | return saddr; |
80 | } | 97 | } |
81 | 98 | ||
@@ -98,9 +115,12 @@ http_common_plugin_string_to_address (void *cls, | |||
98 | void **buf, | 115 | void **buf, |
99 | size_t *added) | 116 | size_t *added) |
100 | { | 117 | { |
101 | GNUNET_assert (NULL != addr); | 118 | if (NULL == addr) |
102 | GNUNET_assert (0 < addrlen); | 119 | return GNUNET_SYSERR; |
103 | GNUNET_assert (addr[addrlen-1] == '\0'); | 120 | if (0 >= addrlen) |
121 | return GNUNET_SYSERR; | ||
122 | if (addr[addrlen-1] != '\0') | ||
123 | return GNUNET_SYSERR; | ||
104 | 124 | ||
105 | (*buf) = strdup (addr); | 125 | (*buf) = strdup (addr); |
106 | (*added) = strlen (addr) + 1; | 126 | (*added) = strlen (addr) + 1; |
@@ -142,11 +162,31 @@ http_common_address_get_size (const void *addr) | |||
142 | * @param addrlen1 address 1 length | 162 | * @param addrlen1 address 1 length |
143 | * @param addr2 address2 | 163 | * @param addr2 address2 |
144 | * @param addrlen2 address 2 length | 164 | * @param addrlen2 address 2 length |
145 | * @return GNUNET_YES if equal, GNUNET_NO else | 165 | * @return GNUNET_YES if equal, GNUNET_NO if not, GNUNET_SYSERR on error |
146 | */ | 166 | */ |
147 | size_t | 167 | int |
148 | http_common_cmp_addresses (const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2) | 168 | http_common_cmp_addresses (const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2) |
149 | { | 169 | { |
170 | const char *a1 = (const char *) addr1; | ||
171 | const char *a2 = (const char *) addr2; | ||
172 | |||
173 | if (NULL == a1) | ||
174 | return GNUNET_SYSERR; | ||
175 | if (0 >= addrlen1) | ||
176 | return GNUNET_SYSERR; | ||
177 | if (a1[addrlen1-1] != '\0') | ||
178 | return GNUNET_SYSERR; | ||
179 | |||
180 | if (NULL == a2) | ||
181 | return GNUNET_SYSERR; | ||
182 | if (0 >= addrlen2) | ||
183 | return GNUNET_SYSERR; | ||
184 | if (a2[addrlen2-1] != '\0') | ||
185 | return GNUNET_SYSERR; | ||
186 | |||
187 | if (addrlen1 != addrlen2) | ||
188 | return GNUNET_NO; | ||
189 | |||
150 | if (0 == strcmp (addr1, addr2)) | 190 | if (0 == strcmp (addr1, addr2)) |
151 | return GNUNET_YES; | 191 | return GNUNET_YES; |
152 | return GNUNET_NO; | 192 | return GNUNET_NO; |