[vlc-commits] [Git][videolan/vlc][master] 6 commits: access: dvdread: fix version logging behavior
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Apr 18 09:57:48 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
c0001e82 by Saifelden Mohamed Ismail at 2026-04-18T09:28:21+00:00
access: dvdread: fix version logging behavior
- - - - -
86c87611 by Saifelden Mohamed Ismail at 2026-04-18T09:28:21+00:00
access: dvdread: version guard for type
- - - - -
b378eb7b by Saifelden Mohamed Ismail at 2026-04-18T09:28:21+00:00
access: dvdread: fix version macro organization
- - - - -
d313efe2 by Saifelden Mohamed Ismail at 2026-04-18T09:28:21+00:00
access: dvdread: validate DVD-VR program index
- - - - -
4cbc562b by Saifelden Mohamed Ismail at 2026-04-18T09:28:21+00:00
access: dvdread: adjust formatting
- - - - -
436a18f2 by Saifelden Mohamed Ismail at 2026-04-18T09:28:21+00:00
access: dvdread: fix DVD-Audio seek overflow
- - - - -
1 changed file:
- modules/access/dvdread.c
Changes:
=====================================
modules/access/dvdread.c
=====================================
@@ -304,43 +304,43 @@ static int OpenCommon( vlc_object_t *p_this , dvd_type_t type )
#else
const char *psz_path = psz_file;
#endif
-#ifdef DVDREAD_HAS_DVDAUDIO
+#if DVDREAD_VERSION >= DVDREAD_VERSION_CODE(6, 1, 0)
dvd_logger_cb cbs = { .pf_log = DvdReadLog };
-
+#endif
dvd_reader_t *p_dvdread;
+#ifdef DVDREAD_HAS_DVDAUDIO
switch (type) {
case DVD_A:
p_dvdread = DVDOpenAudio( p_demux, &cbs, psz_path );
break;
- default:
- p_dvdread = DVDOpen2( p_demux, &cbs, psz_path );
- break;
- }
-#elif DVDREAD_VERSION >= DVDREAD_VERSION_CODE(6, 1, 0)
- dvd_logger_cb cbs = { .pf_log = DvdReadLog };
-
- dvd_reader_t *p_dvdread;
- switch (type) {
- case DVD_A:
+#ifndef DVDREAD_HAS_DVDVIDEORECORDING
case DVD_VR:
- msg_Err( p_demux, "Version of libdvdread does not support this DVD-VideoRecording" );
+ msg_Err( p_demux, "Version of libdvdread does not support DVD-VideoRecording" );
free( psz_file );
return VLC_EGENERIC;
+#endif
default:
p_dvdread = DVDOpen2( p_demux, &cbs, psz_path );
break;
}
+#elif DVDREAD_VERSION >= DVDREAD_VERSION_CODE(6, 1, 0)
+ if ( type != DVD_V )
+ {
+ msg_Err( p_demux, "Version of libdvdread does not support %s",
+ type == DVD_A ? "DVD-Audio" : "DVD-VideoRecording" );
+ free( psz_file );
+ return VLC_EGENERIC;
+ }
+ p_dvdread = DVDOpen2( p_demux, &cbs, psz_path );
#else
- switch (type) {
- case DVD_A:
- case DVD_VR:
- msg_Err( p_demux, "Version of libdvdread does not support this DVD-Audio" );
- free( psz_file );
- return VLC_EGENERIC;
- default:
- dvd_reader_t *p_dvdread = DVDOpen( psz_path );
- break;
+ if ( type != DVD_V )
+ {
+ msg_Err( p_demux, "Version of libdvdread does not support %s",
+ type == DVD_A ? "DVD-Audio" : "DVD-VideoRecording" );
+ free( psz_file );
+ return VLC_EGENERIC;
}
+ p_dvdread = DVDOpen( psz_path );
#endif
#if DVDREAD_VERSION < DVDREAD_VERSION_CODE(6, 1, 2)
LocaleFree( psz_path );
@@ -397,6 +397,7 @@ static int OpenCommon( vlc_object_t *p_this , dvd_type_t type )
/* store type state internally */
/* if open2 is called, in 7.1.0 dvd may force the type */
+#if defined(DVDREAD_HAS_DVDAUDIO)
switch (p_sys->p_vmg_file->ifo_format)
{
#ifdef DVDREAD_HAS_DVDVIDEORECORDING
@@ -413,6 +414,9 @@ static int OpenCommon( vlc_object_t *p_this , dvd_type_t type )
p_sys->type = type;
break;
}
+#else
+ p_sys->type = type;
+#endif
DemuxTitles( p_demux, &p_sys->i_angle );
if( SET_AREA( p_demux, 0, 0, p_sys->i_angle ) != VLC_SUCCESS )
@@ -700,15 +704,14 @@ static int Demux( demux_t *p_demux )
int i_blocks_once, i_read;
bool at_end_of_title =
- (type == DVD_V && p_sys->i_cur_cell >= p_sys->p_cur_pgc->nr_of_cells)
-#if defined(DVDREAD_HAS_DVDAUDIO)
- || (type == DVD_A && p_sys->i_cur_block >= p_sys->i_title_end_block)
-#endif
#if defined(DVDREAD_HAS_DVDVIDEORECORDING)
- || (type == DVD_VR && p_sys->i_cur_cell >= p_sys->i_title_end_cell
- && !p_sys->i_pack_len)
+ (type == DVD_VR && p_sys->i_cur_cell >= p_sys->i_title_end_cell
+ && !p_sys->i_pack_len) ||
#endif
- ;
+#if defined(DVDREAD_HAS_DVDAUDIO)
+ (type == DVD_A && p_sys->i_cur_block >= p_sys->i_title_end_block) ||
+#endif
+ (type == DVD_V && p_sys->i_cur_cell >= p_sys->p_cur_pgc->nr_of_cells);
/*
* Playback by cell in this pgc, starting at the cell for our chapter.
@@ -1547,6 +1550,12 @@ static int DvdVRReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
/* which program we should search for our timestamp */
uint16_t m_vobi_srpn = p_sys->ud_pgcit->m_c_gi[i_start_cell].m_vobi_srpn;
+ if( m_vobi_srpn == 0 || m_vobi_srpn > p_sys->pgc_gi->nr_of_programs )
+ {
+ msg_Err( p_demux, "invalid m_vobi_srpn %u for cell %d",
+ m_vobi_srpn, i_start_cell );
+ return VLC_EGENERIC;
+ }
/* find the corresponding address */
p_sys->p_cur_pgi = &p_sys->pgc_gi->pgi[m_vobi_srpn - 1];
@@ -1559,6 +1568,8 @@ static int DvdVRReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
for( int c = i_start_cell; c < i_end_cell; c++ )
{
uint16_t srpn = p_sys->ud_pgcit->m_c_gi[c].m_vobi_srpn;
+ if( srpn == 0 || srpn > p_sys->pgc_gi->nr_of_programs )
+ continue;
p_sys->i_title_blocks += p_sys->pgc_gi->pgi[srpn - 1].map.nr_of_vobu_info;
}
p_sys->i_title_offset = 0;
@@ -1858,7 +1869,8 @@ static int DvdReadSeek( demux_t *p_demux, uint32_t i_block_offset )
#ifdef DVDREAD_HAS_DVDAUDIO
-static int DvdAudioReadSeek( demux_t *p_demux, uint32_t i_block_offset ){
+static int DvdAudioReadSeek( demux_t *p_demux, uint32_t i_block_offset )
+{
demux_sys_t *p_sys = p_demux->p_sys;
int i_chapter;
uint32_t i_seek_blocks = 0;
@@ -1877,8 +1889,12 @@ static int DvdAudioReadSeek( demux_t *p_demux, uint32_t i_block_offset ){
i_seek_blocks += chapter_len;
}
- if( i_chapter < p_sys->i_chapters &&
- p_sys->cur_chapter != i_chapter )
+
+ /* exit if i_chapter is invalid */
+ if( i_chapter >= p_sys->i_chapters )
+ return VLC_EGENERIC;
+
+ if( p_sys->cur_chapter != i_chapter )
{
p_sys->updates |= INPUT_UPDATE_SEEKPOINT;
p_sys->cur_chapter = i_chapter;
@@ -1903,15 +1919,19 @@ static int DvdVRReadSeek( demux_t *p_demux, uint32_t i_block_offset )
int cell_base = p_sys->ud_pgcit->ud_pgci_items[p_sys->i_title].first_prog_id - 1;
int nr = p_sys->ud_pgcit->ud_pgci_items[p_sys->i_title].nr_of_programs;
+ int found = 0;
for( int c = 0; c < nr; c++ )
{
int cell_idx = cell_base + c;
uint16_t srpn = p_sys->ud_pgcit->m_c_gi[cell_idx].m_vobi_srpn;
+ if( srpn == 0 || srpn > p_sys->pgc_gi->nr_of_programs )
+ continue;
uint16_t cell_vobus = p_sys->pgc_gi->pgi[srpn - 1].map.nr_of_vobu_info;
if( i_block_offset < vobu_accum + cell_vobus )
{
p_sys->i_cur_cell = cell_idx;
+ found = 1;
break;
}
vobu_accum += cell_vobus;
@@ -1920,6 +1940,12 @@ static int DvdVRReadSeek( demux_t *p_demux, uint32_t i_block_offset )
? p_sys->ud_pgcit->m_c_gi[cell_idx].c_epi_n : 1;
}
+ if( !found )
+ {
+ msg_Err( p_demux, "couldn't find cell for block offset %u", i_block_offset );
+ return VLC_EGENERIC;
+ }
+
if( i_chapter < p_sys->i_chapters &&
p_sys->cur_chapter != i_chapter )
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d6b9acc2afa0797345ed285bfd708a3e58858a4d...436a18f2dbb604feeaffe6a46fc822d1abf7a2fd
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d6b9acc2afa0797345ed285bfd708a3e58858a4d...436a18f2dbb604feeaffe6a46fc822d1abf7a2fd
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list