aboutsummaryrefslogtreecommitdiff
path: root/src/hello/hello-ng.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hello/hello-ng.c')
-rw-r--r--src/hello/hello-ng.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c
index dd3480a48..27fd50763 100644
--- a/src/hello/hello-ng.c
+++ b/src/hello/hello-ng.c
@@ -112,12 +112,13 @@ GNUNET_HELLO_extract_address (const void *raw,
112{ 112{
113 const struct GNUNET_CRYPTO_EddsaPublicKey *public_key = &pid->public_key; 113 const struct GNUNET_CRYPTO_EddsaPublicKey *public_key = &pid->public_key;
114 const char *raws = raw; 114 const char *raws = raw;
115 unsigned long long raw_us; 115 unsigned long long raw_us = 0;
116 unsigned int raw_nt; 116 unsigned int raw_nt = 0;
117 const char *sc; 117 const char *sc;
118 const char *sc2; 118 const char *sc2;
119 const char *sc3; 119 const char *sc3;
120 const char *raw_addr; 120 const char *raw_addr;
121 char *data = NULL;
121 struct GNUNET_TIME_Absolute raw_mono_time; 122 struct GNUNET_TIME_Absolute raw_mono_time;
122 struct SignedAddress sa; 123 struct SignedAddress sa;
123 struct GNUNET_CRYPTO_EddsaSignature *sig; 124 struct GNUNET_CRYPTO_EddsaSignature *sig;
@@ -142,22 +143,21 @@ GNUNET_HELLO_extract_address (const void *raw,
142 GNUNET_break_op (0); 143 GNUNET_break_op (0);
143 return NULL; 144 return NULL;
144 } 145 }
145 if (1 != sscanf (sc + 1, "%llu;%u;", &raw_us, &raw_nt)) 146 if (2 != sscanf (sc + 1, "%llu;%u;%*s", &raw_us, &raw_nt))
146 { 147 {
147 GNUNET_break_op (0); 148 GNUNET_break_op (0);
148 return NULL; 149 return NULL;
149 } 150 }
151 raw_addr = sc3 + 1;
150 raw_mono_time.abs_value_us = raw_us; 152 raw_mono_time.abs_value_us = raw_us;
151 sig = NULL; 153 if (sizeof(struct GNUNET_CRYPTO_EddsaSignature) !=
152 if (sizeof(struct GNUNET_CRYPTO_EddsaSignature) != 154 GNUNET_STRINGS_base64_decode (raws, sc - raws, (void **) &data))
153 GNUNET_STRINGS_base64_decode (raws, sc - raws, (void **) &sig))
154 { 155 {
155 GNUNET_break_op (0); 156 GNUNET_break_op (0);
156 GNUNET_free (sig); 157 GNUNET_free (data);
157 return NULL; 158 return NULL;
158 } 159 }
159 raw_addr = sc3 + 1; 160 sig = (struct GNUNET_CRYPTO_EddsaSignature*) data;
160
161 sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS); 161 sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS);
162 sa.purpose.size = htonl (sizeof(sa)); 162 sa.purpose.size = htonl (sizeof(sa));
163 sa.mono_time = GNUNET_TIME_absolute_hton (raw_mono_time); 163 sa.mono_time = GNUNET_TIME_absolute_hton (raw_mono_time);
@@ -169,12 +169,10 @@ GNUNET_HELLO_extract_address (const void *raw,
169 public_key)) 169 public_key))
170 { 170 {
171 GNUNET_break_op (0); 171 GNUNET_break_op (0);
172 GNUNET_free (sig);
173 return NULL; 172 return NULL;
174 } 173 }
175 GNUNET_free (sig);
176 *mono_time = raw_mono_time; 174 *mono_time = raw_mono_time;
177 *nt = (enum GNUNET_NetworkType) raw_nt; 175 *nt = raw_nt;
178 return GNUNET_strdup (raw_addr); 176 return GNUNET_strdup (raw_addr);
179} 177}
180 178