diff mbox series

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

Message ID 20240718191421.110487-4-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: coverity fixes | expand

Commit Message

Martin Wilck July 18, 2024, 7:14 p.m. UTC
Found by coverity.

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

Patch

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;
 }