Add 32-bit size teset only when needed - libcdio.git - libcdio

index : libcdio.git
libcdio
summary refs log tree commit diff
diff options
context:
space:
mode:
authorR. Bernstein <rocky@gnu.org>2024年05月23日 08:57:42 -0400
committerR. Bernstein <rocky@gnu.org>2024年05月23日 08:57:42 -0400
commitb187462adef57fd7a0d8f740af175202a2ed1074 (patch)
tree4a14423b15788a9d17e8fc983852f94733bed155
parent81739d8653988a5cc59fd0ac79ed57f3a4232995 (diff)
downloadlibcdio-mansour-gashasbi-patches.tar.gz
Add 32-bit size teset only when neededmansour-gashasbi-patches
Diffstat
-rw-r--r--lib/iso9660/iso9660_fs.c 7
1 files changed, 6 insertions, 1 deletions
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)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月03日 00:25:50 +0000

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