dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0104-swapon-fix-discard-option-parsing.patch

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