[vlc-commits] [Git][videolan/vlc][3.0.x] cvdsub: do not read header if there is not enough data
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Aug 21 11:57:39 UTC 2026
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
55d6515a by Steve Lhomme at 2026-08-21T11:40:03+00:00
cvdsub: do not read header if there is not enough data
Each block seems to need a 1 octet between valid data (SPU_HEADER_LEN).
We are expecting a header but it's not there, wait for the next packet.
Fixes #30037
(cherry picked from commit 1c21459f7ad8a43e3dc2d3e3596a8ffb361e7dab) (edited)
edited:
- VLC 3 doesn't have VLC_EINVAL
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
1 changed file:
- modules/codec/cvdsub.c
Changes:
=====================================
modules/codec/cvdsub.c
=====================================
@@ -64,7 +64,7 @@ static int Decode( decoder_t *, block_t * );
static block_t *Packetize ( decoder_t *, block_t ** );
static block_t *Reassemble ( decoder_t *, block_t * );
static void ParseMetaInfo ( decoder_t *, block_t * );
-static void ParseHeader ( decoder_t *, block_t * );
+static int ParseHeader ( decoder_t *, block_t * );
static subpicture_t *DecodePacket( decoder_t *, block_t * );
static void RenderImage( decoder_t *, block_t *, subpicture_region_t * );
@@ -250,7 +250,15 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
p_block->i_buffer -= SPU_HEADER_LEN;
/* First packet in the subtitle block */
- if( p_sys->i_state == SUBTITLE_BLOCK_EMPTY ) ParseHeader( p_dec, p_block );
+ if( p_sys->i_state == SUBTITLE_BLOCK_EMPTY )
+ {
+ if( ParseHeader( p_dec, p_block ) != VLC_SUCCESS )
+ {
+ msg_Warn( p_dec, "Missing header data");
+ block_Release( p_block );
+ return NULL;
+ }
+ }
block_ChainAppend( &p_sys->p_spu, p_block );
p_sys->p_spu = block_ChainGather( p_sys->p_spu );
@@ -265,7 +273,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
p_spu->i_buffer, p_sys->i_spu_size );
}
- msg_Dbg( p_dec, "subtitle packet complete, size=%zuu", p_spu->i_buffer);
+ msg_Dbg( p_dec, "subtitle packet complete, size=%zu", p_spu->i_buffer);
ParseMetaInfo( p_dec, p_spu );
@@ -308,10 +316,12 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
this, so it may be untested.
*/
-static void ParseHeader( decoder_t *p_dec, block_t *p_block )
+static int ParseHeader( decoder_t *p_dec, block_t *p_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
uint8_t *p = p_block->p_buffer;
+ if (p_block->i_buffer < 4)
+ return VLC_EGENERIC; // not enough data
p_sys->i_spu_size = (p[0] << 8) + p[1] + 4; p += 2;
@@ -328,6 +338,7 @@ static void ParseHeader( decoder_t *p_dec, block_t *p_block )
msg_Dbg( p_dec, "total size: %zu image size: %zu",
p_sys->i_spu_size, p_sys->i_image_length );
#endif
+ return VLC_SUCCESS;
}
/*
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/55d6515a89b2493a4e46eb601621e4679efbe609
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/55d6515a89b2493a4e46eb601621e4679efbe609
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list