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