From: djm@openbsd.org Date: Thu, 4 Sep 2025 00:31:49 +0000 (+0000) Subject: upstream: fix rtrim() function to not attempt to delete whitespace X-Git-Tag: V_10_1_P1~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e85ad33cfcc71e03594e53f2e19d8ce2e27dcc6;p=thirdparty%2Fopenssh-portable.git upstream: fix rtrim() function to not attempt to delete whitespace inside a string, just at the end. ok deraadt@ OpenBSD-Commit-ID: d44deaa43580cd88de978dd5509b14e905b67b84 --- diff --git a/misc.c b/misc.c index c80f65554..183332082 100644 --- 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); } /*