diff options
author | van <[email protected]> | 2009-01-28 00:46:54 +0000 |
---|---|---|
committer | van <[email protected]> | 2009-01-28 00:46:54 +0000 |
commit | 271785001bdd9c7387649b62ab62823964d13c8c (patch) | |
tree | 9b64fb5a94fae6e42412ecc87810732f57f0601f /libhb | |
parent | fc2ebc097b3c2227113719e707bed0b4f10c8e27 (diff) |
Don't let an invalid PES header length (from a corrupted packet) cause us to crash in memcpy.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2103 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rwxr-xr-x | libhb/stream.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index 5f3358a6d..b50dff15e 100755 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -2081,16 +2081,17 @@ static void hb_ts_stream_find_pids(hb_stream_t *stream) static void fwrite64( hb_stream_t *stream, void *buf, int len ) { - int pos; - - pos = stream->fwrite_buf->size; - if ( pos + len > stream->fwrite_buf->alloc ) + if ( len > 0 ) { - int size = MAX(stream->fwrite_buf->alloc * 2, pos + len); - hb_buffer_realloc(stream->fwrite_buf, size); + int pos = stream->fwrite_buf->size; + if ( pos + len > stream->fwrite_buf->alloc ) + { + int size = MAX(stream->fwrite_buf->alloc * 2, pos + len); + hb_buffer_realloc(stream->fwrite_buf, size); + } + memcpy( &(stream->fwrite_buf->data[pos]), buf, len ); + stream->fwrite_buf->size += len; } - memcpy( &(stream->fwrite_buf->data[pos]), buf, len ); - stream->fwrite_buf->size += len; } // convert a PES PTS or DTS to an int64 |