Skip to content

Commit

Permalink
libext2fs: fix potential divide by zero bug caused by a lxcfs bug
Browse files Browse the repository at this point in the history
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.

#114
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
tytso committed May 2, 2024
1 parent 66b0b3c commit b88b3b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ext2fs/rw_bitmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b88b3b4

Please sign in to comment.