From: Christian Grothoff Date: Sun, 22 Nov 2009 13:44:14 +0000 (+0000) Subject: fixing bug in bio.c triggered by test_pseudonym.c X-Git-Tag: initial-import-from-subversion-38251~23029 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8ca761fc103ec014d5ab3dc51660861fa8bd7472;p=oweals%2Fgnunet.git fixing bug in bio.c triggered by test_pseudonym.c --- diff --git a/src/util/bio.c b/src/util/bio.c index 1143e89de..102d3df50 100644 --- a/src/util/bio.c +++ b/src/util/bio.c @@ -209,13 +209,12 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, char *buf; struct GNUNET_CONTAINER_MetaData *meta; - if (GNUNET_BIO_read_int32__ (h, what, (int32_t *) & size) != GNUNET_OK) + if (GNUNET_BIO_read_int32__ (h, what, (int32_t *) &size) != GNUNET_OK) return GNUNET_SYSERR; if (size > MAX_META_DATA) { GNUNET_asprintf (&h->emsg, - _ - ("Serialized metadata `%s' larger than allowed (%u > %u)"), + _("Serialized metadata `%s' larger than allowed (%u>%u)"), what, size, MAX_META_DATA); return GNUNET_SYSERR; } @@ -432,24 +431,26 @@ int GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m) { - unsigned int size; + ssize_t size; char *buf; size = GNUNET_CONTAINER_meta_data_get_serialized_size (m, GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL | GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS); + if (size == -1) + return GNUNET_SYSERR; if (size > MAX_META_DATA) - size = MAX_META_DATA; + size = MAX_META_DATA; buf = GNUNET_malloc (size); - GNUNET_CONTAINER_meta_data_serialize (m, - buf, - size, - GNUNET_CONTAINER_META_DATA_SERIALIZE_PART - | - GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS); - if ((GNUNET_OK != GNUNET_BIO_write_int32 (h, size)) - || (GNUNET_OK != GNUNET_BIO_write (h, buf, size))) + size = GNUNET_CONTAINER_meta_data_serialize (m, + buf, + size, + GNUNET_CONTAINER_META_DATA_SERIALIZE_PART + | + GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS); + if ( (GNUNET_OK != GNUNET_BIO_write_int32 (h, (uint32_t) size)) || + (GNUNET_OK != GNUNET_BIO_write (h, buf, size)) ) { GNUNET_free (buf); return GNUNET_SYSERR;