From 054c6c890a5cde082e5a62f1e7c7a50479a32420 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 6 Sep 2011 18:24:27 +0000 Subject: [PATCH] Detect sscanf recovering_region input error Missing check for sscanf found by static analyzer. --- WHATS_NEW | 1 + daemons/cmirrord/functions.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 600402467..daf41a7ed 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Detect sscanf recovering_region input error in cmirrord pull_state(). Fix error path bitmap leak in cmirrord import_checkpoint(). Log unlink() error in cmirrord remove_lockfile(). Remove incorrect requirement for -j or -m from lvchange error message. diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c index de807936d..161121059 100644 --- a/daemons/cmirrord/functions.c +++ b/daemons/cmirrord/functions.c @@ -1817,8 +1817,11 @@ int pull_state(const char *uuid, uint64_t luid, } if (!strncmp(which, "recovering_region", 17)) { - sscanf(buf, "%llu %u", (unsigned long long *)&lc->recovering_region, - &lc->recoverer); + if (sscanf(buf, "%llu %u", (unsigned long long *)&lc->recovering_region, + &lc->recoverer) != 2) { + LOG_ERROR("cannot parse recovering region from: %s", buf); + return -EINVAL; + } LOG_SPRINT(lc, "CKPT INIT - SEQ#=X, UUID=%s, nodeid = X:: " "recovering_region=%llu, recoverer=%u", SHORT_UUID(lc->uuid),