64664a
From 294a277fceb5cd6640a9b7a6e8af7b2567150f34 Mon Sep 17 00:00:00 2001
64664a
From: Karel Zak <kzak@redhat.com>
64664a
Date: Mon, 20 Mar 2017 12:03:40 +0100
64664a
Subject: [PATCH 104/116] swapon: fix discard option parsing
64664a
64664a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1378100
64664a
Upstream: https://github.com/karelzak/util-linux/commit/07332bfa1ec122a251194a62f91319841121d5aa
64664a
Signed-off-by: Karel Zak <kzak@redhat.com>
64664a
---
64664a
 sys-utils/swapon.c | 7 ++++---
64664a
 1 file changed, 4 insertions(+), 3 deletions(-)
64664a
64664a
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
64664a
index d85b910..d4f2c08 100644
64664a
--- a/sys-utils/swapon.c
64664a
+++ b/sys-utils/swapon.c
64664a
@@ -632,20 +632,21 @@ static int swapon_all(void)
64664a
 
64664a
 	while (mnt_table_find_next_fs(tb, itr, match_swap, NULL, &fs) == 0) {
64664a
 		/* defaults */
64664a
+		size_t argsz = 0;
64664a
 		int pri = priority, dsc = discard, nofail = ifexists;
64664a
 		char *p, *src, *dscarg;
64664a
 
64664a
 		if (mnt_fs_get_option(fs, "noauto", NULL, NULL) == 0)
64664a
 			continue;
64664a
-		if (mnt_fs_get_option(fs, "discard", &dscarg, NULL) == 0) {
64664a
+		if (mnt_fs_get_option(fs, "discard", &dscarg, &argsz) == 0) {
64664a
 			dsc |= SWAP_FLAG_DISCARD;
64664a
 			if (dscarg) {
64664a
 				/* only single-time discards are wanted */
64664a
-				if (strcmp(dscarg, "once") == 0)
64664a
+				if (strncmp(dscarg, "once", argsz) == 0)
64664a
 					dsc |= SWAP_FLAG_DISCARD_ONCE;
64664a
 
64664a
 				/* do discard for every released swap page */
64664a
-				if (strcmp(dscarg, "pages") == 0)
64664a
+				if (strncmp(dscarg, "pages", argsz) == 0)
64664a
 					dsc |= SWAP_FLAG_DISCARD_PAGES;
64664a
 			}
64664a
 		}
64664a
-- 
64664a
2.9.3
64664a