support empty strings

This commit is contained in:
j 2014-07-19 16:24:01 +02:00
parent 142e478c51
commit 44d68e19d7

View file

@ -730,14 +730,16 @@ ne_read_string(nestegg * ctx, char ** val, uint64_t length)
char * str;
int r;
if (length == 0 || length > LIMIT_STRING)
if (length > LIMIT_STRING)
return -1;
str = ne_pool_alloc(length + 1, ctx->alloc_pool);
if (!str)
return -1;
r = ne_io_read(ctx->io, (unsigned char *) str, length);
if (r != 1)
return r;
if (length) {
r = ne_io_read(ctx->io, (unsigned char *) str, length);
if (r != 1)
return r;
}
str[length] = '\0';
*val = str;
return 1;