libext2fs: avoid pointer arithmetic on `void *`
PATCH 1/1 libext2fs: avoid pointer arithmetic on `void *`
The pointer operand to the binary + operator must be to a complete object type.
Signed-off-by Michael Forney <[email protected]>
--- lib/ext2fs/csum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ext2fs/csum.c +1 -1
@@ -274,7 +274,7 @@ static errcode_t __get_dirent_tail(ext2_filsys fs, rec_len =translate (d->rec_len); } -if ((void *)d > ((void *)dirent + fs->blocksize)) +if ((char *)d > ((char *)dirent + fs->blocksize))return EXT2_ET_DIR_CORRUPTED ;if (d != top)return EXT2_ET_DIR_NO_SPACE_FOR_CSUM ;
Signature · 1 line
2.26.0
Quoted 5 lines · Michael Forney
The pointer operand to the binary
+operator must be to a complete object type.Signed-off-by Michael Forney <[email protected]>
Seems straight forward enough. Not needed for GCC, but strictly correct.
Reviewed-by Andreas Dilger <[email protected]>
Quoted 18 lines
---
lib/ext2fs/csum.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/ext2fs/csum.c +1
-2@@ -274,7 +274,7 @@ static errcode_t __get_dirent_tail(ext2_filsys fs, rec_len =translate (d->rec_len); } -if ((void *)d > ((void *)dirent + fs->blocksize)) +if ((char *)d > ((char *)dirent + fs->blocksize))return EXT2_ET_DIR_CORRUPTED ;if (d != top)return EXT2_ET_DIR_NO_SPACE_FOR_CSUM ; --
Quoted 2 lines
2.26.0
Cheers, Andreas
Theodore Y. Ts'o
AppliedQuoted 10 lines · Andreas Dilger
Quoted 5 lines · Michael Forney
The pointer operand to the binary
+operator must be to a complete object type.Signed-off-by Michael Forney <[email protected]>Seems straight forward enough. Not needed for GCC, but strictly correct.
Reviewed-by Andreas Dilger <[email protected]>
Applied, thanks.
- Ted