mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-24 10:33:35 +08:00
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" <tytso@mit.edu>
This commit is contained in:
parent
c2dbc18a94
commit
df200fffd5
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user