[PATCH 3/4] libmpathutil: avoid size_t underflow in strchop()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Found by coverity.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmpathutil/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libmpathutil/util.c b/libmpathutil/util.c
index 67db3c8..9c422f1 100644
--- a/libmpathutil/util.c
+++ b/libmpathutil/util.c
@@ -27,8 +27,8 @@ strchop(char *str)
 {
 	size_t i;
 
-	for (i = strlen(str) - 1; i != (size_t) -1 && isspace(str[i]); i--) ;
-	str[++i] = '\0';
+	for (i = strlen(str); i != 0 && isspace(str[i - 1]); i--) ;
+	str[i] = '\0';
 	return i;
 }
 
-- 
2.45.2





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux