aboutsummaryrefslogtreecommitdiff
path: root/src/util/bio.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-06 13:02:30 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-06 13:02:30 +0000
commit471306e8d1dbeaeaea7c84e49cb650e76ea254fb (patch)
tree9b459d523d74430ee3396ffb6166aaed60a4939c /src/util/bio.c
parent0b41a005a697d23fedef619df03597e6c308a6c1 (diff)
downloadgnunet-471306e8d1dbeaeaea7c84e49cb650e76ea254fb.tar.gz
gnunet-471306e8d1dbeaeaea7c84e49cb650e76ea254fb.zip
better
Diffstat (limited to 'src/util/bio.c')
-rw-r--r--src/util/bio.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/util/bio.c b/src/util/bio.c
index ef31547be..976da7e01 100644
--- a/src/util/bio.c
+++ b/src/util/bio.c
@@ -129,6 +129,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
129 GNUNET_asprintf (&h->emsg, 129 GNUNET_asprintf (&h->emsg,
130 _("Error reading `%s': %s"), 130 _("Error reading `%s': %s"),
131 what, STRERROR (errno)); 131 what, STRERROR (errno));
132 abort ();
132 return GNUNET_SYSERR; 133 return GNUNET_SYSERR;
133 } 134 }
134 if (ret == 0) 135 if (ret == 0)
@@ -136,6 +137,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
136 GNUNET_asprintf (&h->emsg, 137 GNUNET_asprintf (&h->emsg,
137 _("Error reading `%s': %s"), 138 _("Error reading `%s': %s"),
138 what, _("End of file")); 139 what, _("End of file"));
140 abort ();
139 return GNUNET_SYSERR; 141 return GNUNET_SYSERR;
140 } 142 }
141 h->pos = 0; 143 h->pos = 0;
@@ -188,7 +190,13 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
188 uint32_t big; 190 uint32_t big;
189 191
190 if (GNUNET_OK != GNUNET_BIO_read_int32 (h, &big)) 192 if (GNUNET_OK != GNUNET_BIO_read_int32 (h, &big))
191 return GNUNET_SYSERR; 193 {
194 GNUNET_free_non_null (h->emsg);
195 GNUNET_asprintf (&h->emsg,
196 _("Error reading length of string `%s'"),
197 what);
198 return GNUNET_SYSERR;
199 }
192 if (big == 0) 200 if (big == 0)
193 { 201 {
194 *result = NULL; 202 *result = NULL;
@@ -235,6 +243,11 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
235 243
236 if (GNUNET_BIO_read_int32 (h, (int32_t *) &size) != GNUNET_OK) 244 if (GNUNET_BIO_read_int32 (h, (int32_t *) &size) != GNUNET_OK)
237 return GNUNET_SYSERR; 245 return GNUNET_SYSERR;
246 if (size == 0)
247 {
248 *result = NULL;
249 return GNUNET_OK;
250 }
238 if (size > MAX_META_DATA) 251 if (size > MAX_META_DATA)
239 { 252 {
240 GNUNET_asprintf (&h->emsg, 253 GNUNET_asprintf (&h->emsg,
@@ -463,7 +476,9 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
463{ 476{
464 ssize_t size; 477 ssize_t size;
465 char *buf; 478 char *buf;
466 479
480 if (m == NULL)
481 return GNUNET_BIO_write_int32 (h, 0);
467 buf = NULL; 482 buf = NULL;
468 size = GNUNET_CONTAINER_meta_data_serialize (m, 483 size = GNUNET_CONTAINER_meta_data_serialize (m,
469 &buf, 484 &buf,