linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsck.f2fs: do not hard-code encrypted filename length to avoid heap buffer overflow
@ 2018-10-10  0:46 Jaegeuk Kim
  2018-10-15 12:09 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2018-10-10  0:46 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

From: Randall Huang <huangrandall@google.com>

If the len is less than 24, heap buffer overflow is reported.

Signed-off-by: Randall Huang <huangrandall@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 85d9823..1fc168f 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1170,10 +1170,12 @@ int convert_encrypted_name(unsigned char *name, u32 len,
 		memcpy(new, name, len);
 		new[len] = 0;
 		return len;
+	} else if (len != 24) {
+		ASSERT_MSG("len: %d, encrypted name must be 24\n", len);
 	}
 
 	*new = '_';
-	return digest_encode((const char *)name, 24, (char *)new + 1);
+	return digest_encode((const char *)name, len, (char *)new + 1);
 }
 
 static void print_dentry(__u32 depth, __u8 *name,
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-15 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-10  0:46 [PATCH] fsck.f2fs: do not hard-code encrypted filename length to avoid heap buffer overflow Jaegeuk Kim
2018-10-15 12:09 ` Chao Yu
2018-10-15 23:05   ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).