aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord/gnsrecord_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord/gnsrecord_misc.c')
-rw-r--r--src/gnsrecord/gnsrecord_misc.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 9da5bd920..3298168f4 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -264,16 +264,18 @@ GNUNET_GNSRECORD_identity_from_data (const char *data,
264{ 264{
265 if (GNUNET_NO == GNUNET_GNSRECORD_is_zonekey_type (type)) 265 if (GNUNET_NO == GNUNET_GNSRECORD_is_zonekey_type (type))
266 return GNUNET_SYSERR; 266 return GNUNET_SYSERR;
267 if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey))
268 return GNUNET_SYSERR;
269 switch (type) 267 switch (type)
270 { 268 {
271 case GNUNET_GNSRECORD_TYPE_PKEY: 269 case GNUNET_GNSRECORD_TYPE_PKEY:
272 memcpy (&key->ecdsa_key, data, data_size); 270 if (data_size > sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))
273 break; 271 return GNUNET_SYSERR;
274 case GNUNET_GNSRECORD_TYPE_EDKEY: 272 memcpy (&key->ecdsa_key, data, data_size);
275 memcpy (&key->eddsa_key, data, data_size); 273 break;
276 break; 274 case GNUNET_GNSRECORD_TYPE_EDKEY:
275 if (data_size > sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))
276 return GNUNET_SYSERR;
277 memcpy (&key->eddsa_key, data, data_size);
278 break;
277 default: 279 default:
278 return GNUNET_NO; 280 return GNUNET_NO;
279 } 281 }
@@ -296,7 +298,7 @@ GNUNET_GNSRECORD_data_from_identity (const struct
296 if (0 == *data_size) 298 if (0 == *data_size)
297 return GNUNET_SYSERR; 299 return GNUNET_SYSERR;
298 tmp = GNUNET_malloc (*data_size); 300 tmp = GNUNET_malloc (*data_size);
299 memcpy (tmp, ((char*)key) + sizeof (key->type), *data_size); 301 memcpy (tmp, ((char*) key) + sizeof (key->type), *data_size);
300 *data = tmp; 302 *data = tmp;
301 return GNUNET_OK; 303 return GNUNET_OK;
302} 304}