From e042869209267a331dde4924965d1cfdf9b50c9b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 10 Mar 2018 19:44:37 -0500 Subject: [PATCH] misc/fsck: fix potential memory leak on error path Signed-off-by: Theodore Ts'o --- misc/fsck.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; -- 1.8.3.1