fs: KASAN error in nls uniname cmp [1/1]

PD#SWPL-6404

Problem:
KASAN error:global-out-of-bounds in nls_uniname_cmp

Solution:
Append "\0\0" to the string of UNI_CUR_DIR_NAME and UNI_PAR_DIR_NAME

Verify:
x301

Change-Id: Ic94e837ed7874d337207c31eedfc966b46ab8ecd
Signed-off-by: changqing.gao <changqing.gao@amlogic.com>
This commit is contained in:
changqing.gao
2019-04-01 13:57:55 +08:00
committed by Luke Go
parent c329f60c6b
commit ceff2f8513
2 changed files with 5 additions and 5 deletions

View File

@@ -106,7 +106,7 @@ s32 nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b)
for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
if (nls_upper(sb, *a) != nls_upper(sb, *b))
return 1;
if (*a == 0x0)
if ((*a == 0x0) || (*b == 0x0))
return 0;
}
return 0;

View File

@@ -48,11 +48,11 @@
#define DOS_PAR_DIR_NAME ".. "
#ifdef __LITTLE_ENDIAN
#define UNI_CUR_DIR_NAME ".\0"
#define UNI_PAR_DIR_NAME ".\0.\0"
#define UNI_CUR_DIR_NAME ".\0\0\0"
#define UNI_PAR_DIR_NAME ".\0.\0\0\0"
#else
#define UNI_CUR_DIR_NAME "\0."
#define UNI_PAR_DIR_NAME "\0.\0."
#define UNI_CUR_DIR_NAME "\0.\0\0"
#define UNI_PAR_DIR_NAME "\0.\0.\0\0"
#endif
/*----------------------------------------------------------------------*/