diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2022-02-25 08:45:00 +0100 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2022-02-25 08:48:59 +0100 |
commit | 86e73d58ffc79ea706a5bc83867de3def4eaba48 (patch) | |
tree | 54cba66ad309dab2523bcff41ac29e79450fd64f | |
parent | 6a7b95964b53d6ae4e7a7c54e08070bd6ddaa95e (diff) | |
download | gnunet-86e73d58ffc79ea706a5bc83867de3def4eaba48.tar.gz gnunet-86e73d58ffc79ea706a5bc83867de3def4eaba48.zip |
-gix record handling
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 28 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_to_name.c | 6 | ||||
-rwxr-xr-x | src/namestore/test_namestore_delete.sh | 10 |
3 files changed, 20 insertions, 24 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index fe6af44c0..662c64713 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -266,10 +266,20 @@ GNUNET_GNSRECORD_identity_from_data (const char *data, | |||
266 | return GNUNET_SYSERR; | 266 | return GNUNET_SYSERR; |
267 | if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) | 267 | if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) |
268 | return GNUNET_SYSERR; | 268 | return GNUNET_SYSERR; |
269 | return (GNUNET_IDENTITY_read_key_from_buffer (key, data, data_size) == | 269 | switch (type) |
270 | data_size? | 270 | { |
271 | GNUNET_OK : | 271 | case GNUNET_GNSRECORD_TYPE_PKEY: |
272 | GNUNET_SYSERR); | 272 | memcpy (&key->ecdsa_key, data, data_size); |
273 | break; | ||
274 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
275 | memcpy (&key->eddsa_key, data, data_size); | ||
276 | break; | ||
277 | default: | ||
278 | return GNUNET_NO; | ||
279 | } | ||
280 | key->type = htonl (type); | ||
281 | |||
282 | return GNUNET_YES; | ||
273 | } | 283 | } |
274 | 284 | ||
275 | 285 | ||
@@ -282,17 +292,11 @@ GNUNET_GNSRECORD_data_from_identity (const struct | |||
282 | { | 292 | { |
283 | char *tmp; | 293 | char *tmp; |
284 | *type = ntohl (key->type); | 294 | *type = ntohl (key->type); |
285 | *data_size = GNUNET_IDENTITY_key_get_length (key); | 295 | *data_size = GNUNET_IDENTITY_key_get_length (key) - sizeof (key->type); |
286 | if (0 == *data_size) | 296 | if (0 == *data_size) |
287 | return GNUNET_SYSERR; | 297 | return GNUNET_SYSERR; |
288 | tmp = GNUNET_malloc (*data_size); | 298 | tmp = GNUNET_malloc (*data_size); |
289 | if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size) | 299 | memcpy (tmp, ((char*)key) + sizeof (key->type), *data_size); |
290 | != *data_size) | ||
291 | { | ||
292 | GNUNET_free (tmp); | ||
293 | *data_size = 0; | ||
294 | return GNUNET_SYSERR; | ||
295 | } | ||
296 | *data = tmp; | 300 | *data = tmp; |
297 | return GNUNET_OK; | 301 | return GNUNET_OK; |
298 | } | 302 | } |
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c index 3fd10e4a1..8efdba453 100644 --- a/src/namestore/test_namestore_api_zone_to_name.c +++ b/src/namestore/test_namestore_api_zone_to_name.c | |||
@@ -218,8 +218,8 @@ run (void *cls, | |||
218 | 218 | ||
219 | rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us; | 219 | rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us; |
220 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | 220 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; |
221 | rd.data_size = GNUNET_IDENTITY_key_get_length (&s_zone_value); | 221 | rd.data_size = sizeof (s_zone_value.ecdsa_key); |
222 | rd.data = &s_zone_value; | 222 | rd.data = &s_zone_value.ecdsa_key; |
223 | rd.flags = 0; | 223 | rd.flags = 0; |
224 | 224 | ||
225 | nsh = GNUNET_NAMESTORE_connect (cfg); | 225 | nsh = GNUNET_NAMESTORE_connect (cfg); |
@@ -230,7 +230,7 @@ run (void *cls, | |||
230 | 1, | 230 | 1, |
231 | &rd, | 231 | &rd, |
232 | &put_cont, | 232 | &put_cont, |
233 | NULL); | 233 | s_name); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
diff --git a/src/namestore/test_namestore_delete.sh b/src/namestore/test_namestore_delete.sh index 44ea1e66c..b861a4bc0 100755 --- a/src/namestore/test_namestore_delete.sh +++ b/src/namestore/test_namestore_delete.sh | |||
@@ -61,15 +61,7 @@ for LINE in $OUTPUT ; | |||
61 | stop_peer | 61 | stop_peer |
62 | 62 | ||
63 | 63 | ||
64 | if [ $FOUND_NAME = false -a $FOUND_IP != false ] | 64 | if [ $FOUND_IP = true ] |
65 | then | ||
66 | echo "PASS: Delete name in namestore" | ||
67 | exit 0 | ||
68 | elif [ $FOUND_NAME = true ] | ||
69 | then | ||
70 | echo "FAIL: Delete name in namestore: name returned" | ||
71 | exit 1 | ||
72 | elif [ $FOUND_IP = true ] | ||
73 | then | 65 | then |
74 | echo "FAIL: Delete name in namestore: IP returned" | 66 | echo "FAIL: Delete name in namestore: IP returned" |
75 | exit 1 | 67 | exit 1 |