diff options
Diffstat (limited to 'src/transport/transport_api_address_to_string.c')
-rw-r--r-- | src/transport/transport_api_address_to_string.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c index 87ee9ad83..5c44c288b 100644 --- a/src/transport/transport_api_address_to_string.c +++ b/src/transport/transport_api_address_to_string.c | |||
@@ -125,13 +125,16 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf | |||
125 | { | 125 | { |
126 | size_t len; | 126 | size_t len; |
127 | size_t alen; | 127 | size_t alen; |
128 | size_t slen; | ||
128 | struct AddressLookupMessage *msg; | 129 | struct AddressLookupMessage *msg; |
129 | struct GNUNET_TRANSPORT_AddressToStringContext *alc; | 130 | struct GNUNET_TRANSPORT_AddressToStringContext *alc; |
130 | struct GNUNET_CLIENT_Connection *client; | 131 | struct GNUNET_CLIENT_Connection *client; |
131 | char *addrbuf; | 132 | char *addrbuf; |
132 | 133 | ||
133 | GNUNET_assert (address != NULL); | 134 | GNUNET_assert (address != NULL); |
134 | len = sizeof (struct AddressLookupMessage) + GNUNET_HELLO_address_get_size (address); | 135 | alen = address->address_length; |
136 | slen = strlen (address->transport_name) + 1; | ||
137 | len = sizeof (struct AddressLookupMessage) + alen + slen; | ||
135 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 138 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
136 | { | 139 | { |
137 | GNUNET_break (0); | 140 | GNUNET_break (0); |
@@ -141,19 +144,19 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf | |||
141 | client = GNUNET_CLIENT_connect ("transport", cfg); | 144 | client = GNUNET_CLIENT_connect ("transport", cfg); |
142 | if (client == NULL) | 145 | if (client == NULL) |
143 | return NULL; | 146 | return NULL; |
147 | #if DEBUG_TRANSPORT | ||
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
145 | "GNUNET_TRANSPORT_address_to_string\n"); | 149 | "GNUNET_TRANSPORT_address_to_string\n"); |
146 | 150 | #endif | |
147 | alen = address->address_length; | ||
148 | msg = GNUNET_malloc (len); | 151 | msg = GNUNET_malloc (len); |
149 | msg->header.size = htons (len); | 152 | msg->header.size = htons (len); |
150 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING); | 153 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING); |
151 | msg->numeric_only = htonl (numeric); | 154 | msg->numeric_only = htons ((int16_t) numeric); |
155 | msg->addrlen = htons ((uint16_t) alen); | ||
152 | msg->timeout = GNUNET_TIME_relative_hton (timeout); | 156 | msg->timeout = GNUNET_TIME_relative_hton (timeout); |
153 | msg->addrlen = htonl (alen); | ||
154 | addrbuf = (char *) &msg[1]; | 157 | addrbuf = (char *) &msg[1]; |
155 | memcpy (addrbuf, address->address, alen); | 158 | memcpy (addrbuf, address->address, alen); |
156 | strcpy (&addrbuf[alen], address->transport_name); | 159 | memcpy (&addrbuf[alen], address->transport_name, slen); |
157 | 160 | ||
158 | alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_AddressToStringContext)); | 161 | alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_AddressToStringContext)); |
159 | alc->cb = aluc; | 162 | alc->cb = aluc; |