diff options
author | Andreas Dilger <adilger@dilger.ca> | 2020-01-14 14:42:17 -0700 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-01-24 23:06:58 -0500 |
commit | 6b430d60caf6c4080bd32783659a819425657b69 (patch) | |
tree | a967fd33e368bf2a36bdadfca333c1276939862d /misc/dumpe2fs.c | |
parent | f6c5ad97daf7b266d66987476da33d6dfe341b36 (diff) | |
download | e2fsprogs-6b430d60caf6c4080bd32783659a819425657b69.tar.gz |
mmp: don't assume NUL termination for MMP strings
Don't assume that mmp_nodename and mmp_bdevname are NUL terminated,
since very long node/device names may completely fill the buffers.
Limit string printing to the maximum buffer size for safety, and
change the field definitions to __u8 to make it more clear that
they are not NUL-terminated strings, as is done with other strings
in the superblock that do not have NUL termination.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/dumpe2fs.c')
-rw-r--r-- | misc/dumpe2fs.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index 384ce925..403cd4f6 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -439,8 +439,12 @@ static int check_mmp(ext2_filsys fs) time_t mmp_time = mmp->mmp_time; fprintf(stderr, - "%s: MMP last updated by '%s' on %s", - program_name, mmp->mmp_nodename, + "%s: MMP update by '%.*s%.*s' at %s", + program_name, + (int)sizeof(mmp->mmp_nodename), + (char *)mmp->mmp_nodename, + (int)sizeof(mmp->mmp_bdevname), + (char *)mmp->mmp_bdevname, ctime(&mmp_time)); } retval = 1; @@ -489,8 +493,10 @@ static void print_mmp_block(ext2_filsys fs) printf(" mmp_sequence: %#08x\n", mmp->mmp_seq); printf(" mmp_update_date: %s", ctime(&mmp_time)); printf(" mmp_update_time: %lld\n", mmp->mmp_time); - printf(" mmp_node_name: %s\n", mmp->mmp_nodename); - printf(" mmp_device_name: %s\n", mmp->mmp_bdevname); + printf(" mmp_node_name: %.*s\n", + (int)sizeof(mmp->mmp_nodename), (char *)mmp->mmp_nodename); + printf(" mmp_device_name: %.*s\n", + (int)sizeof(mmp->mmp_bdevname), (char *)mmp->mmp_bdevname); } static void parse_extended_opts(const char *opts, blk64_t *superblock, |