{
char * str;
int r;
+ const size_t alloc_size = (size_t)length + 1;
if (length == 0 || length > LIMIT_STRING)
return -1;
- str = ne_pool_alloc(length + 1, ctx->alloc_pool);
- r = ne_io_read(ctx->io, (unsigned char *) str, length);
+ str = ne_pool_alloc(alloc_size, ctx->alloc_pool);
+ r = ne_io_read(ctx->io, (unsigned char *) str, alloc_size - 1);
if (r != 1)
return r;
- str[length] = '\0';
+ str[alloc_size - 1] = '\0';
*val = str;
return 1;
}
{
if (length == 0 || length > LIMIT_BINARY)
return -1;
- val->data = ne_pool_alloc(length, ctx->alloc_pool);
- val->length = length;
- return ne_io_read(ctx->io, val->data, length);
+ val->length = (size_t)length;
+ val->data = ne_pool_alloc(val->length, ctx->alloc_pool);
+ return ne_io_read(ctx->io, val->data, val->length);
}
static int
if (track_number == 0 || (unsigned int)track_number != track_number)
return -1;
- consumed += length;
+ assert(length <= 8);
+ consumed += (size_t)length;
r = ne_read_int(ctx->io, &timecode, 2);
if (r != 1)
case LACING_XIPH:
if (frames == 1)
return -1;
- r = ne_read_xiph_lacing(ctx->io, block_size, &consumed, frames, frame_sizes);
+ r = ne_read_xiph_lacing(ctx->io, (size_t)block_size, &consumed, frames, frame_sizes);
if (r != 1)
return r;
break;
case LACING_EBML:
if (frames == 1)
return -1;
- r = ne_read_ebml_lacing(ctx->io, block_size, &consumed, frames, frame_sizes);
+ r = ne_read_ebml_lacing(ctx->io, (size_t)block_size, &consumed, frames, frame_sizes);
if (r != 1)
return r;
break;
return -1;
}
f = ne_alloc(sizeof(*f));
- f->data = ne_alloc(frame_sizes[i]);
- f->length = frame_sizes[i];
- r = ne_io_read(ctx->io, f->data, frame_sizes[i]);
+ f->length = (size_t)frame_sizes[i];
+ f->data = ne_alloc(f->length);
+ r = ne_io_read(ctx->io, f->data, f->length);
if (r != 1) {
free(f->data);
free(f);
p += sizes[i];
}
*data = p;
- *length = sizes[item];
+ *length = (size_t)sizes[item];
} else {
*data = codec_private.data;
*length = codec_private.length;