aboutsummaryrefslogtreecommitdiff
path: root/src/util/bio.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-11-05 13:50:25 +0000
committerChristian Grothoff <christian@grothoff.org>2009-11-05 13:50:25 +0000
commit3e697f238da8de2bc490d33da0660afc1dd14fbf (patch)
tree6061e140c38024a93ae53ae613fabd4a9b1a42d1 /src/util/bio.c
parent98428e91dd5a9cd97ad9fa4599ab2fd20b0b9244 (diff)
downloadgnunet-3e697f238da8de2bc490d33da0660afc1dd14fbf.tar.gz
gnunet-3e697f238da8de2bc490d33da0660afc1dd14fbf.zip
fixes
Diffstat (limited to 'src/util/bio.c')
-rw-r--r--src/util/bio.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util/bio.c b/src/util/bio.c
index 860e9e63e..1143e89de 100644
--- a/src/util/bio.c
+++ b/src/util/bio.c
@@ -58,6 +58,8 @@ GNUNET_BIO_read_open (const char *fn)
58 58
59 fd = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ, 59 fd = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ,
60 GNUNET_DISK_PERM_NONE); 60 GNUNET_DISK_PERM_NONE);
61 if (NULL == fd)
62 return NULL;
61 h = GNUNET_malloc (sizeof (struct GNUNET_BIO_ReadHandle) + BIO_BUFFER_SIZE); 63 h = GNUNET_malloc (sizeof (struct GNUNET_BIO_ReadHandle) + BIO_BUFFER_SIZE);
62 h->buffer = (char *) &h[1]; 64 h->buffer = (char *) &h[1];
63 h->size = BIO_BUFFER_SIZE; 65 h->size = BIO_BUFFER_SIZE;
@@ -176,15 +178,16 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
176 return GNUNET_SYSERR; 178 return GNUNET_SYSERR;
177 } 179 }
178 buf = GNUNET_malloc (big); 180 buf = GNUNET_malloc (big);
181 *result = buf;
179 buf[--big] = '\0'; 182 buf[--big] = '\0';
180 if (big == 0) 183 if (big == 0)
181 return GNUNET_OK; 184 return GNUNET_OK;
182 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big)) 185 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big))
183 { 186 {
184 GNUNET_free (buf); 187 GNUNET_free (buf);
188 *result = NULL;
185 return GNUNET_SYSERR; 189 return GNUNET_SYSERR;
186 } 190 }
187 *result = buf;
188 return GNUNET_OK; 191 return GNUNET_OK;
189} 192}
190 193
@@ -308,6 +311,8 @@ GNUNET_BIO_write_open (const char *fn)
308 GNUNET_DISK_OPEN_CREATE, 311 GNUNET_DISK_OPEN_CREATE,
309 GNUNET_DISK_PERM_USER_READ | 312 GNUNET_DISK_PERM_USER_READ |
310 GNUNET_DISK_PERM_USER_WRITE); 313 GNUNET_DISK_PERM_USER_WRITE);
314 if (NULL == fd)
315 return NULL;
311 h = 316 h =
312 GNUNET_malloc (sizeof (struct GNUNET_BIO_WriteHandle) + BIO_BUFFER_SIZE); 317 GNUNET_malloc (sizeof (struct GNUNET_BIO_WriteHandle) + BIO_BUFFER_SIZE);
313 h->buffer = (char *) &h[1]; 318 h->buffer = (char *) &h[1];
@@ -390,6 +395,7 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
390 h->have = 0; 395 h->have = 0;
391 } 396 }
392 while (pos < n); /* should always be true */ 397 while (pos < n); /* should always be true */
398 GNUNET_break (0);
393 return GNUNET_OK; 399 return GNUNET_OK;
394} 400}
395 401