From: Dmitry V. Levin Date: Sat, 20 Oct 2007 18:08:20 +0000 (+0400) Subject: e2image: Fix potential off-by-one fs_device_name buffer overflow X-Git-Tag: v1.41-WIP-0427~118 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84d51a2e99277dfb728edc7c5e06273a49d197f5;p=thirdparty%2Fe2fsprogs.git e2image: Fix potential off-by-one fs_device_name buffer overflow In write_image_file(), fix length argument of strncat(3) call. Signed-off-by: Dmitry V. Levin Signed-off-by: Theodore Ts'o --- diff --git a/misc/e2image.c b/misc/e2image.c index 1fbb2676a..44f48976f 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -126,8 +126,7 @@ static void write_image_file(ext2_filsys fs, int fd) hdr.magic_number = EXT2_ET_MAGIC_E2IMAGE; strcpy(hdr.magic_descriptor, "Ext2 Image 1.0"); gethostname(hdr.fs_hostname, sizeof(hdr.fs_hostname)); - strncat(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name)); - hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0; + strncat(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name) - 1); hdr.fs_blocksize = fs->blocksize; if (stat(device_name, &st) == 0)