mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
Fix writes out of bounds in the ogg demuxer.
Between ogg_save() and ogg_restore() calls, the number of streams could have been reduced. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
340e6735fe
commit
bc851a2946
@ -29,7 +29,6 @@
|
|||||||
DEALINGS IN THE SOFTWARE.
|
DEALINGS IN THE SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "oggdec.h"
|
#include "oggdec.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
@ -93,14 +92,24 @@ static int ogg_restore(AVFormatContext *s, int discard)
|
|||||||
ogg->state = ost->next;
|
ogg->state = ost->next;
|
||||||
|
|
||||||
if (!discard){
|
if (!discard){
|
||||||
|
struct ogg_stream *old_streams = ogg->streams;
|
||||||
|
|
||||||
for (i = 0; i < ogg->nstreams; i++)
|
for (i = 0; i < ogg->nstreams; i++)
|
||||||
av_free (ogg->streams[i].buf);
|
av_free (ogg->streams[i].buf);
|
||||||
|
|
||||||
avio_seek (bc, ost->pos, SEEK_SET);
|
avio_seek (bc, ost->pos, SEEK_SET);
|
||||||
ogg->curidx = ost->curidx;
|
ogg->curidx = ost->curidx;
|
||||||
ogg->nstreams = ost->nstreams;
|
ogg->nstreams = ost->nstreams;
|
||||||
memcpy(ogg->streams, ost->streams,
|
ogg->streams = av_realloc (ogg->streams,
|
||||||
ost->nstreams * sizeof(*ogg->streams));
|
ogg->nstreams * sizeof (*ogg->streams));
|
||||||
|
|
||||||
|
if (ogg->streams) {
|
||||||
|
memcpy(ogg->streams, ost->streams,
|
||||||
|
ost->nstreams * sizeof(*ogg->streams));
|
||||||
|
} else {
|
||||||
|
av_free(old_streams);
|
||||||
|
ogg->nstreams = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
av_free (ost);
|
av_free (ost);
|
||||||
|
Loading…
Reference in New Issue
Block a user