diff options
author | wm4 <wm4@nowhere> | 2014-12-10 14:36:16 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-10 14:37:35 +0100 |
commit | 10a2f69347b3e2889435eeae7e427ab029555e31 (patch) | |
tree | eca0a155c7a3d01ddf3473588ae7c007d9254a0d /demux | |
parent | f6d7230a6fba0ab8040b1ebbdec7d3a5e2627640 (diff) | |
download | mpv-10a2f69347b3e2889435eeae7e427ab029555e31.tar.bz2 mpv-10a2f69347b3e2889435eeae7e427ab029555e31.tar.xz |
emux_mkv: fix possible uninitialized reads with short files
These actually are harmless. Even if the data the reader is working on
is essentially random, it's treated like untrusted input data, so there
should be no harm.
But it upsets tools like valgrind.
Probably fixes #1329.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/ebml.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/demux/ebml.c b/demux/ebml.c index d94aed5f64..540a0e8897 100644 --- a/demux/ebml.c +++ b/demux/ebml.c @@ -616,8 +616,10 @@ int ebml_read_element(struct stream *s, struct ebml_parse_ctx *ctx, } ctx->talloc_ctx = talloc_size(NULL, length + 8); int read_len = stream_read(s, ctx->talloc_ctx, length); - if (read_len < length) + if (read_len < length) { MP_MSG(ctx, msglevel, "Unexpected end of file - partial or corrupt file?\n"); + memset((char *)ctx->talloc_ctx + read_len, 0, length - read_len); + } ebml_parse_element(ctx, target, ctx->talloc_ctx, read_len, desc, 0); if (ctx->has_errors) MP_MSG(ctx, msglevel, "Error parsing element %s\n", desc->name); |