From: Theodore Ts'o Date: Sun, 27 Jan 2008 20:45:30 +0000 (-0500) Subject: e2image: Fix potential overflow if the device name is too long X-Git-Tag: v1.40.5~5 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=df200fffd5276d3c8ba201fd61858ba906b77cf6;p=tools%2Fe2fsprogs.git e2image: Fix potential overflow if the device name is too long Adapted from SLES's patch: e2fsprogs-strncat.patch Signed-off-by: "Theodore Ts'o" --- diff --git a/misc/e2image.c b/misc/e2image.c index f17b784..4313cc0 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -126,7 +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)); + strncpy(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name)-1); hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0; hdr.fs_blocksize = fs->blocksize;