]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: fix rtrim() function to not attempt to delete whitespace
authordjm@openbsd.org <djm@openbsd.org>
Thu, 4 Sep 2025 00:31:49 +0000 (00:31 +0000)
committerDamien Miller <djm@mindrot.org>
Thu, 4 Sep 2025 03:06:18 +0000 (13:06 +1000)
inside a string, just at the end. ok deraadt@

OpenBSD-Commit-ID: d44deaa43580cd88de978dd5509b14e905b67b84

misc.c

diff --git a/misc.c b/misc.c
index c80f65554a7e14d06182fe5768a3de0f26043a48..183332082b5a0991266a0b9225ebdf0d28c337a8 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.205 2025/09/04 00:30:06 djm Exp $ */
+/* $OpenBSD: misc.c,v 1.206 2025/09/04 00:31:49 djm Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2005-2020 Damien Miller.  All rights reserved.
@@ -101,10 +101,13 @@ rtrim(char *s)
 
        if ((i = strlen(s)) == 0)
                return;
-       for (i--; i > 0; i--) {
+       do {
+               i--;
                if (isspace((unsigned char)s[i]))
                        s[i] = '\0';
-       }
+               else
+                       break;
+       } while (i > 0);
 }
 
 /*