Skip to contentSkip to conversation

master - cov: check sscanf result

PATCH Zdenek Kabelac 1 participant 1 message Sep 12, 2020

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=740d5bf6cd39015aac086ddca98a089ba6028d72
Commit:        740d5bf6cd39015aac086ddca98a089ba6028d72
Parent:        a5d45b237dbb6d9c1984fd98ba84bce9bde0ea99
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sat Sep 12 13:03:07 2020 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Sat Sep 12 13:24:03 2020 +0200

cov: check sscanf result

---
 daemons/lvmlockd/lvmlockd-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
daemons/lvmlockd/lvmlockd-core.c +2 -2
index a0803de39..fea8ee6cf 100644
@@ -887,8 +887,8 @@ static int read_adopt_file(struct list_head *vg_lockd)
 			continue;
 		else if (!strncmp(adopt_line, "lvmlockd", 8)) {
 			unsigned int v_major = 0, v_minor = 0;
-			sscanf(adopt_line, "lvmlockd adopt_version %u.%u", &v_major, &v_minor);
-			if (v_major != ADOPT_VERSION_MAJOR)
+			if ((sscanf(adopt_line, "lvmlockd adopt_version %u.%u", &v_major, &v_minor) != 2) ||
+			    (v_major != ADOPT_VERSION_MAJOR))
 				goto fail;
 
 		} else if (!strncmp(adopt_line, "VG:", 3)) {