[PATCH 09/15] mke2fs: check return value of e2p_os2string()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



e2p_os2string() calls malloc() so that it can return NULL.
Check it.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
---
 misc/mke2fs.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 9fb5d5f..90cc206 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -554,6 +554,10 @@ static void show_stats(ext2_filsys fs)
 	printf(_("Filesystem label=%s\n"), buf);
 	fputs(_("OS type: "), stdout);
         os = e2p_os2string(fs->super->s_creator_os);
+	if (!os) {
+		fprintf(stderr, _("Couldn't allocate memory to show OS name!\n"));
+		exit(1);
+	}
 	fputs(os, stdout);
 	free(os);
 	printf("\n");
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux