lkml.org 
[lkml]   [2018]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] fsck.f2fs: fix to avoid accessing invalid memory address
Date
This patch adds to check return value of calloc in write_superblock().

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fsck/mount.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fsck/mount.c b/fsck/mount.c
index 7e936dc056e5..badbe639742e 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -2155,6 +2155,7 @@ void write_superblock(struct f2fs_super_block *new_sb)
u_int8_t *buf;

buf = calloc(BLOCK_SZ, 1);
+ ASSERT(buf);

memcpy(buf + F2FS_SUPER_OFFSET, new_sb, sizeof(*new_sb));
for (index = 0; index < 2; index++) {
--
2.15.0.55.gc2ece9dc4de6
\
 
 \ /
  Last update: 2018-04-23 08:02    [W:0.173 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site