libcdio.git - libcdio

index : libcdio.git
libcdio
summary refs log tree commit diff
diff options
context:
space:
mode:
authorMansour Gashasbi <gashasbi@gmail.com>2024年05月19日 09:52:32 -0700
committerR. Bernstein <rocky@gnu.org>2024年05月21日 13:45:46 -0400
commit455b6982a007f04e1d81d8a1a97e7ca9b0a2e170 (patch)
tree816516b0a5e078e6e0232d00e700f64b4886df55
parent7b346798a7f9afc1f1080914741eb24dad58803f (diff)
downloadlibcdio-455b6982a007f04e1d81d8a1a97e7ca9b0a2e170.tar.gz
Fix overflow in iso9660 dir read (32-bit)
Diffstat
-rw-r--r--lib/iso9660/iso9660_fs.c 20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/iso9660/iso9660_fs.c b/lib/iso9660/iso9660_fs.c
index 5cd1f759..4e261044 100644
--- a/lib/iso9660/iso9660_fs.c
+++ b/lib/iso9660/iso9660_fs.c
@@ -1509,6 +1509,16 @@ iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[])
}
{
+ // **Fix for overflow on 32-bit systems**
+ //
+ // uint32_t has a limited maximum value, and if p_stat->total_size (the total
+ // size of the directory) is very large, the calculation might exceed this limit.
+
+ if (p_stat->total_size > SIZE_MAX / ISO_BLOCKSIZE) {
+ cdio_warn("Total size is too large");
+ iso9660_stat_free(p_stat);
+ return NULL;
+ }
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
uint32_t blocks = CDIO_EXTENT_BLOCKS(p_stat->total_size);
@@ -1606,6 +1616,16 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[])
}
{
+ // **Fix for overflow on 32-bit systems**
+ //
+ // uint32_t has a limited maximum value, and if p_stat->total_size (the total
+ // size of the directory) is very large, the calculation might exceed this limit.
+
+ if (p_stat->total_size > SIZE_MAX / ISO_BLOCKSIZE) {
+ cdio_warn("Total size is too large");
+ iso9660_stat_free(p_stat);
+ return NULL;
+ }
long int ret;
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
generated by cgit v1.2.3 (git 2.25.1) at 2025年10月03日 19:04:53 +0000

AltStyle によって変換されたページ (->オリジナル) /