[libdvdnav-devel] [Git][videolan/libdvdread][master] 4 commits: nav_read: zero-initialize the PCI structure before parsing

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Aug 4 10:35:29 UTC 2026



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread


Commits:
534350c1 by Jean-Baptiste Kempf at 2026-08-04T12:18:48+02:00
nav_read: zero-initialize the PCI structure before parsing

navRead_PCI fills the structure field by field. Now that pci_t is no
longer packed, it needs init.

- - - - -
f5b14960 by Jean-Baptiste Kempf at 2026-08-04T12:18:48+02:00
nav_types, ifo_types: save and restore packing with push/pop

These installed public headers switched the compiler to pack(1) with a
bare '#pragma pack()' to end the region.
Pack() resets the packing to default rather than restoring it, so an application that
includes the header from inside its own '#pragma pack(N)' fails now.

- - - - -
d20e29d6 by Jean-Baptiste Kempf at 2026-08-04T12:18:48+02:00
ifo_read: drop duplicate structure size checks

- - - - -
47497242 by Jean-Baptiste Kempf at 2026-08-04T12:18:48+02:00
ifo_read: byte-swap the remaining ATSI_MAT sector fields

vts_ptt_srpt and vtsm_pgci_ut are 32-bit sector pointers in the public
atsi_mat_t and are printed by ifoPrint_ATSI_MAT, but ifoRead_ATS never
byte-swapped them, so they read reversed on little-endian hosts.

- - - - -


4 changed files:

- src/dvdread/ifo_types.h
- src/dvdread/nav_types.h
- src/ifo_read.c
- src/nav_read.c


Changes:

=====================================
src/dvdread/ifo_types.h
=====================================
@@ -39,7 +39,7 @@
 #endif
 
 #if PRAGMA_PACK
-#pragma pack(1)
+#pragma pack(push, 1)
 #endif
 
 
@@ -1334,7 +1334,7 @@ typedef struct  {
 #define CI_OFFSET_SIZE 4U
 
 #if PRAGMA_PACK
-#pragma pack()
+#pragma pack(pop)
 #endif
 
 


=====================================
src/dvdread/nav_types.h
=====================================
@@ -44,7 +44,7 @@
 #define DSI_START_BYTE 1031
 
 #if PRAGMA_PACK
-#pragma pack(1)
+#pragma pack(push, 1)
 #endif
 
 /**
@@ -115,7 +115,7 @@ typedef struct {
 /* btni_t, hli_t and pci_t are not read as packed structures but bit by bit
  * in navRead_PCI(), they must not be packed */
 #if PRAGMA_PACK
-#pragma pack()
+#pragma pack(pop)
 #endif
 
 /**
@@ -167,7 +167,7 @@ typedef struct {
 } pci_t;
 
 #if PRAGMA_PACK
-#pragma pack(1)
+#pragma pack(push, 1)
 #endif
 
 
@@ -258,7 +258,7 @@ typedef struct {
 
 
 #if PRAGMA_PACK
-#pragma pack()
+#pragma pack(pop)
 #endif
 
 #endif /* LIBDVDREAD_NAV_TYPES_H */


=====================================
src/ifo_read.c
=====================================
@@ -205,8 +205,6 @@ CHECK_STRUCT_SIZE(m_c_gi_t,               1, M_C_GI_SIZE);
 CHECK_STRUCT_SIZE(m_c_epi_t,              0, M_C_EPI_SIZE);
 CHECK_STRUCT_SIZE(ats_pg_asv_pbi_srp_t,   0, ATS_PG_ASV_PBI_SRP_SIZE);
 CHECK_STRUCT_SIZE(asv_dlist_t,            0, ASV_DLIST_SIZE);
-CHECK_STRUCT_SIZE(asvu_gi_t,              0, ASVU_GI_SIZE);
-CHECK_STRUCT_SIZE(asvs_mat_t,             1, ASVS_MAT_SIZE);
 CHECK_STRUCT_SIZE(audio_attr_vr_t,        0, AUDIO_ATTR_VR_SIZE);
 CHECK_STRUCT_SIZE(cprm_info_t,            0, CPRM_INFO_SIZE);
 CHECK_STRUCT_SIZE(pgtm_t,                 0, PGTM_SIZE);
@@ -2009,8 +2007,10 @@ static int ifoRead_ATS(ifo_handle_t *ifofile) {
   B2N_32(atsi_mat->atsi_last_sector);
   B2N_32(atsi_mat->vts_sa);
   B2N_32(atsi_mat->atst_aobs);
+  B2N_32(atsi_mat->vts_ptt_srpt);
   B2N_32(atsi_mat->atsi_last_byte);
   B2N_32(atsi_mat->ats_pgci_ut);
+  B2N_32(atsi_mat->vtsm_pgci_ut);
   B2N_32(atsi_mat->vts_tmapt);
   B2N_32(atsi_mat->vtsm_c_adt);
   B2N_32(atsi_mat->vtsm_vobu_admap);


=====================================
src/nav_read.c
=====================================
@@ -72,6 +72,11 @@ void navRead_PCI(pci_t *pci, unsigned char *buffer) {
   getbits_state_t state;
   if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */
 
+  /* pci_t is no longer packed, so it now has padding bytes that the field by
+   * field parsing below never writes; clear them to keep the whole structure
+   * deterministic for callers that copy or hash it. */
+  memset(pci, 0, sizeof(*pci));
+
   /* pci pci_gi */
   pci->pci_gi.nv_pck_lbn = getbits(&state, 32 );
   pci->pci_gi.vobu_cat = getbits(&state, 16 );



View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/cf82b9739ced24bb15648e788f9d3425eb4110ba...47497242d98847f2861115664b3d29221023a084

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/cf82b9739ced24bb15648e788f9d3425eb4110ba...47497242d98847f2861115664b3d29221023a084
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 libdvdnav-devel mailing list