From: Theodore Ts'o Date: Sun, 11 Mar 2018 00:44:37 +0000 (-0500) Subject: misc/fsck: fix potential memory leak on error path X-Git-Tag: v1.44.1~17 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=e042869209267a331dde4924965d1cfdf9b50c9b;p=tools%2Fe2fsprogs.git misc/fsck: fix potential memory leak on error path Signed-off-by: Theodore Ts'o --- diff --git a/misc/fsck.c b/misc/fsck.c index a2e0dfb..cd23537 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -441,13 +441,14 @@ static int execute(const char *type, const char *device, const char *mntpt, struct fsck_instance *inst, *p; pid_t pid; + if (snprintf(prog, sizeof(prog), "fsck.%s", type) >= sizeof(prog)) + return EINVAL; + inst = malloc(sizeof(struct fsck_instance)); if (!inst) return ENOMEM; memset(inst, 0, sizeof(struct fsck_instance)); - if (snprintf(prog, sizeof(prog), "fsck.%s", type) >= sizeof(prog)) - return EINVAL; argv[0] = string_copy(prog); argc = 1;