From 5aed93c3e04548d305909600a885643a0f0b07b6 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Mon, 16 Jan 2012 00:20:24 -0800 Subject: [PATCH] LU-752 lfsck: compare EA name correctly In e2fsck_lfsck_find_ea(), it compares EA name by calling strncmp on the EA name pairs directly, without length checking. This is wrong because the passed in EA entry could be an empty entry with 0 EA name length, or it's name could be a sub-string of the comparing one. Singed-off-by: Ken Hornstein Signed-off-by: Niu Yawei Change-Id: Ib79ea217e67a6702eee2f41155562a775f6c1578 --- patches/e2fsprogs-lfsck.patch | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/patches/e2fsprogs-lfsck.patch b/patches/e2fsprogs-lfsck.patch index cfabc41..2115b0b 100644 --- a/patches/e2fsprogs-lfsck.patch +++ b/patches/e2fsprogs-lfsck.patch @@ -3739,7 +3739,7 @@ Index: e2fsprogs/e2fsck/pass6.c =================================================================== --- /dev/null +++ e2fsprogs/e2fsck/pass6.c -@@ -0,0 +1,1551 @@ +@@ -0,0 +1,1556 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim:shiftwidth=8:tabstop=8: + * @@ -4184,6 +4184,9 @@ Index: e2fsprogs/e2fsck/pass6.c + if (!LINUX_S_ISREG(inode->i_mode)) + return 0; + ++ if (entry->e_name_len == 0) ++ return 0; ++ + if (entry->e_name_index == EXT3_XATTR_INDEX_TRUSTED && + entry->e_name_index == EXT3_XATTR_INDEX_LUSTRE) + return 0; @@ -4211,7 +4214,8 @@ Index: e2fsprogs/e2fsck/pass6.c + memcpy(ea, value, entry->e_value_size); + } + -+ if (strncmp(entry->e_name, XATTR_LUSTRE_MDS_LOV_EA, ++ if (entry->e_name_len == strlen(XATTR_LUSTRE_MDS_LOV_EA) && ++ strncmp(entry->e_name, XATTR_LUSTRE_MDS_LOV_EA, + entry->e_name_len) == 0) { + if (*lmm) { + ext2fs_free_mem(&ea); @@ -4226,7 +4230,8 @@ Index: e2fsprogs/e2fsck/pass6.c + ext2fs_free_mem(&ea); + return -EINVAL; + } -+ } else if (strncmp(entry->e_name, XATTR_LUSTRE_MDT_LMA_EA, ++ } else if (entry->e_name_len == strlen(XATTR_LUSTRE_MDT_LMA_EA) && ++ strncmp(entry->e_name, XATTR_LUSTRE_MDT_LMA_EA, + entry->e_name_len) == 0) { + if (*lma) { + ext2fs_free_mem(&ea); -- 1.8.3.1