Skip to content

Commit

Permalink
xfstests: fix modulo-by-zero error in fsx
Browse files Browse the repository at this point in the history
The recent fsx fixes has a logic error in the offset trimming code.
If a read is done when the file size is zero, then the logic error
causes a offset % 0 opertaion to occur. This causes fsx to get a
SIGFPE and die.

This was not discovered during my testing because I was using a
random seed that didn't trip this condition. Changing the seed to
that which test 091 uses (the default of 1) causes such an operation
to occur....

Signed-off-by: Dave Chinner <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Dave Chinner authored and dchinner committed Jul 19, 2011
1 parent 407191f commit c47d7a5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ltp/fsx.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,14 +987,14 @@ docloseopen(void)
}
}

#define TRIM_OFF_LEN(off, len, size, zero_offset) \
do { \
if (!zero_offset || file_size) \
offset %= size; \
else \
offset = 0; \
if (offset + len > size) \
len = size - offset; \
#define TRIM_OFF_LEN(off, len, size, allow_zero_file_size) \
do { \
if (allow_zero_file_size || file_size) \
offset %= size; \
else \
offset = 0; \
if (offset + len > size) \
len = size - offset; \
} while (0)

void
Expand Down

0 comments on commit c47d7a5

Please sign in to comment.