aboutsummaryrefslogtreecommitdiff
path: root/src/util/bio.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-10-19 22:28:37 +0000
committerChristian Grothoff <christian@grothoff.org>2009-10-19 22:28:37 +0000
commit09cfcd83bd680bd5178c7fead1c6927fcf45b352 (patch)
tree2e96207c413407d1a487035c9136807b1ffa5b37 /src/util/bio.c
parent8da07c23a94221fea5d73ebac9a522f72e3adef3 (diff)
downloadgnunet-09cfcd83bd680bd5178c7fead1c6927fcf45b352.tar.gz
gnunet-09cfcd83bd680bd5178c7fead1c6927fcf45b352.zip
fixing bio bugs
Diffstat (limited to 'src/util/bio.c')
-rw-r--r--src/util/bio.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/util/bio.c b/src/util/bio.c
index 83afa34f3..20870576b 100644
--- a/src/util/bio.c
+++ b/src/util/bio.c
@@ -169,7 +169,7 @@ int GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
169 char *buf; 169 char *buf;
170 uint32_t big; 170 uint32_t big;
171 171
172 if (! GNUNET_BIO_read_int32 (h, &big)) 172 if (GNUNET_OK != GNUNET_BIO_read_int32 (h, &big))
173 return GNUNET_SYSERR; 173 return GNUNET_SYSERR;
174 if (big == 0) 174 if (big == 0)
175 { 175 {
@@ -187,7 +187,7 @@ int GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
187 } 187 }
188 buf = GNUNET_malloc (big); 188 buf = GNUNET_malloc (big);
189 buf[--big] = '\0'; 189 buf[--big] = '\0';
190 if (big != GNUNET_BIO_read (h, what, buf, big)) 190 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big))
191 { 191 {
192 GNUNET_free (buf); 192 GNUNET_free (buf);
193 return GNUNET_SYSERR; 193 return GNUNET_SYSERR;
@@ -227,7 +227,7 @@ int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
227 return GNUNET_SYSERR; 227 return GNUNET_SYSERR;
228 } 228 }
229 buf = GNUNET_malloc (size); 229 buf = GNUNET_malloc (size);
230 if (size != 230 if (GNUNET_OK !=
231 GNUNET_BIO_read (h, what, buf, size)) 231 GNUNET_BIO_read (h, what, buf, size))
232 { 232 {
233 GNUNET_free (buf); 233 GNUNET_free (buf);
@@ -262,7 +262,7 @@ int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h,
262{ 262{
263 int32_t big; 263 int32_t big;
264 264
265 if (sizeof (int32_t) != 265 if (GNUNET_OK !=
266 GNUNET_BIO_read (h, 266 GNUNET_BIO_read (h,
267 what, 267 what,
268 &big, 268 &big,
@@ -287,7 +287,7 @@ int GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h,
287{ 287{
288 int64_t big; 288 int64_t big;
289 289
290 if (sizeof (int64_t) != 290 if (GNUNET_OK !=
291 GNUNET_BIO_read (h, 291 GNUNET_BIO_read (h,
292 what, 292 what,
293 &big, 293 &big,
@@ -342,6 +342,7 @@ struct GNUNET_BIO_WriteHandle *GNUNET_BIO_write_open (const char *fn)
342 */ 342 */
343int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h) 343int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h)
344{ 344{
345 ssize_t wrt;
345 int ret; 346 int ret;
346 347
347 if (NULL == h->fd) 348 if (NULL == h->fd)
@@ -350,8 +351,12 @@ int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h)
350 } 351 }
351 else 352 else
352 { 353 {
354 wrt = GNUNET_DISK_file_write (h->fd, h->buffer, h->have);
355 if (wrt == h->have)
356 ret = GNUNET_OK;
357 else
358 ret = GNUNET_SYSERR;
353 GNUNET_DISK_file_close (h->fd); 359 GNUNET_DISK_file_close (h->fd);
354 ret = GNUNET_OK;
355 } 360 }
356 GNUNET_free (h); 361 GNUNET_free (h);
357 return ret; 362 return ret;