forked from mia/Aegisub
Don't limit CodecPrivate to 256KB
This commit is contained in:
parent
f522d4df8a
commit
5830fc4225
1 changed files with 15 additions and 3 deletions
|
@ -151,6 +151,8 @@ struct MatroskaFile {
|
|||
int bufpos; // current read position in buffer
|
||||
int buflen; // valid bytes in buffer
|
||||
|
||||
void *cpbuf;
|
||||
|
||||
// error reporting
|
||||
char errmsg[128];
|
||||
jmp_buf jb;
|
||||
|
@ -407,6 +409,9 @@ static void myvsnprintf(char *dest,unsigned dsize,const char *fmt,va_list ap)
|
|||
static void errorjmp(MatroskaFile *mf,const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
mf->cache->memfree(mf->cache, mf->cpbuf);
|
||||
mf->cpbuf = NULL;
|
||||
|
||||
va_start(ap, fmt);
|
||||
myvsnprintf(mf->errmsg,sizeof(mf->errmsg),fmt,ap);
|
||||
va_end(ap);
|
||||
|
@ -1330,9 +1335,13 @@ static void parseTrackEntry(MatroskaFile *mf,uint64_t toplen) {
|
|||
case 0x63a2: // CodecPrivate
|
||||
if (cp)
|
||||
errorjmp(mf,"Duplicate CodecPrivate");
|
||||
if (len>262144) // 256KB
|
||||
errorjmp(mf,"CodecPrivate is too large: %d",(int)len);
|
||||
cplen = (unsigned)len;
|
||||
if (len > 262144) { // 256KB
|
||||
cp = mf->cpbuf = mf->cache->memalloc(mf->cache, cplen);
|
||||
if (!cp)
|
||||
errorjmp(mf,"Out of memory");
|
||||
}
|
||||
else
|
||||
cp = alloca(cplen);
|
||||
readbytes(mf,cp,(int)cplen);
|
||||
break;
|
||||
|
@ -1514,9 +1523,12 @@ static void parseTrackEntry(MatroskaFile *mf,uint64_t toplen) {
|
|||
|
||||
static void parseTracks(MatroskaFile *mf,uint64_t toplen) {
|
||||
mf->seen.Tracks = 1;
|
||||
mf->cpbuf = NULL;
|
||||
FOREACH(mf,toplen)
|
||||
case 0xae: // TrackEntry
|
||||
parseTrackEntry(mf,len);
|
||||
mf->cache->memfree(mf->cache, mf->cpbuf);
|
||||
mf->cpbuf = NULL;
|
||||
break;
|
||||
ENDFOR(mf);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue