From: Brian Behlendorf Date: Wed, 21 Mar 2007 19:09:15 +0000 (-0400) Subject: [COVERITY] Avoid static buffer overruns in debugfs X-Git-Tag: E2FSPROGS-1_40~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b772900b4bcff407c883b7bd8419af56be0a9823;p=thirdparty%2Fe2fsprogs.git [COVERITY] Avoid static buffer overruns in debugfs Add an extra byte to EXT2_NAME_LEN in the static allocation for the required trailing null. This allows filenames up to the maximum length of EXT2_NAME_LEN withover an overrun. Coverity ID: 11: Overrun Static Coverity ID: 12: Overrun Static Coverity ID: 13: Overrun Static Signed-off-by: Brian Behlendorf Signed-off-by: "Theodore Ts'o" --- diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index aaed95022..ae7d09b14 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,10 @@ +2007-03-21 Theodore Tso + + * dump.c (rdump_dirent), htree.c (htree_dump_leaf_node), + ls.c (list_dir_proc): Add an extra byte to EXT2_NAME_LEN + to avoid the possibility of an array overrun if the + filename is exactly EXT2_NAME_LEN in size. + 2007-03-07 Theodore Tso * debugfs.c (do_lcd): Allow the lcd command when debugfs does not diff --git a/debugfs/dump.c b/debugfs/dump.c index fbaf703e0..577959e71 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -292,7 +292,7 @@ static int rdump_dirent(struct ext2_dir_entry *dirent, int blocksize EXT2FS_ATTR((unused)), char *buf EXT2FS_ATTR((unused)), void *private) { - char name[EXT2_NAME_LEN]; + char name[EXT2_NAME_LEN + 1]; int thislen; const char *dumproot = private; struct ext2_inode inode; diff --git a/debugfs/htree.c b/debugfs/htree.c index 7abdfc025..2d51ec3ab 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -35,7 +35,7 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino, struct ext2_dir_entry *dirent; int thislen, col = 0; unsigned int offset = 0; - char name[EXT2_NAME_LEN]; + char name[EXT2_NAME_LEN + 1]; char tmp[EXT2_NAME_LEN + 16]; blk_t pblk; ext2_dirhash_t hash; diff --git a/debugfs/ls.c b/debugfs/ls.c index 8e97ce8b6..ffb2310e9 100644 --- a/debugfs/ls.c +++ b/debugfs/ls.c @@ -52,7 +52,7 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)), ext2_ino_t ino; struct tm *tm_p; time_t modtime; - char name[EXT2_NAME_LEN]; + char name[EXT2_NAME_LEN + 1]; char tmp[EXT2_NAME_LEN + 16]; char datestr[80]; char lbr, rbr;