author | R. Bernstein <rocky@gnu.org> | 2024年05月23日 08:57:42 -0400 |
---|---|---|
committer | R. Bernstein <rocky@gnu.org> | 2024年05月23日 08:57:42 -0400 |
commit | b187462adef57fd7a0d8f740af175202a2ed1074 (patch) | |
tree | 4a14423b15788a9d17e8fc983852f94733bed155 | |
parent | 81739d8653988a5cc59fd0ac79ed57f3a4232995 (diff) | |
download | libcdio-mansour-gashasbi-patches.tar.gz |
-rw-r--r-- | lib/iso9660/iso9660_fs.c | 7 |
diff --git a/lib/iso9660/iso9660_fs.c b/lib/iso9660/iso9660_fs.c index 2374d463..7ff6c73b 100644 --- a/lib/iso9660/iso9660_fs.c +++ b/lib/iso9660/iso9660_fs.c @@ -1514,6 +1514,7 @@ iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[]) return NULL; } +#if (SIZE_MAX / 2048) < UINT32_MAX /* Check 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. @@ -1523,16 +1524,20 @@ iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[]) iso9660_stat_free(p_stat); return NULL; } +#endif blocks = CDIO_EXTENT_BLOCKS(p_stat->total_size); retval = _cdio_list_new (); - /* Check for potential integer overflow when calculating total blocks */ +#if (SIZE_MAX / 2048) < UINT32_MAX + /* Check for potential integer overflow on 32-bit systems when + calculating total blocks */ if (blocks > (SIZE_MAX / ISO_BLOCKSIZE)) { cdio_warn("Total size is too large"); iso9660_stat_free(p_stat); return NULL; } +#endif _dirbuf = calloc(1, blocks * ISO_BLOCKSIZE); if (!_dirbuf) |