fd = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ,
GNUNET_DISK_PERM_NONE);
+ if (NULL == fd)
+ return NULL;
h = GNUNET_malloc (sizeof (struct GNUNET_BIO_ReadHandle) + BIO_BUFFER_SIZE);
h->buffer = (char *) &h[1];
h->size = BIO_BUFFER_SIZE;
return GNUNET_SYSERR;
}
buf = GNUNET_malloc (big);
+ *result = buf;
buf[--big] = '\0';
if (big == 0)
return GNUNET_OK;
if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big))
{
GNUNET_free (buf);
+ *result = NULL;
return GNUNET_SYSERR;
}
- *result = buf;
return GNUNET_OK;
}
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;
}
GNUNET_DISK_OPEN_CREATE,
GNUNET_DISK_PERM_USER_READ |
GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == fd)
+ return NULL;
h =
GNUNET_malloc (sizeof (struct GNUNET_BIO_WriteHandle) + BIO_BUFFER_SIZE);
h->buffer = (char *) &h[1];
h->have = 0;
}
while (pos < n); /* should always be true */
+ GNUNET_break (0);
return GNUNET_OK;
}
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 > 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)))
+ buf = NULL;
+ size = GNUNET_CONTAINER_meta_data_serialize (m,
+ &buf,
+ MAX_META_DATA,
+ GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
+ if (size == -1)
+ {
+ GNUNET_free (buf);
+ return GNUNET_SYSERR;
+ }
+ 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;