aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2024-05-02 12:23:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2024-05-02 12:23:44 -0400
commitb88b3b46cf1cfd4f0682374918fb3ba4aa0decdd (patch)
tree62208a506854f34fcf0c714b032f11f85e101078
parent66b0b3c1fc6262605d38f443641cdb9ab09d14e2 (diff)
downloade2fsprogs-next.tar.gz
libext2fs: fix potential divide by zero bug caused by a lxcfs bugHEADnextmaster
If sysconf(_SC_NPROCESSORS_CONF) returns zero, this can cause a divide by zero. Make ext2fs_rw_bitmaps() more robust defaulting to 4 threads if _SC_NPROCESSORS_CONF returns an invalid value. https://github.com/tytso/e2fsprogs/issues/114 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/rw_bitmaps.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 1fe65f744..1da75e4a0 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -557,7 +557,7 @@ errcode_t ext2fs_rw_bitmaps(ext2_filsys fs, int flags, int num_threads)
* MacOS, FreeBSD, etc.
* ref: https://stackoverflow.com/questions/150355
*/
- if (num_threads < 0)
+ if (num_threads <= 0)
num_threads = 4;
if ((unsigned) num_threads > fs->group_desc_count)