]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: The idiomatic way of coping with signed char vs unsigned
authorderaadt@openbsd.org <deraadt@openbsd.org>
Thu, 15 Dec 2022 18:20:39 +0000 (18:20 +0000)
committerDarren Tucker <dtucker@dtucker.net>
Tue, 3 Jan 2023 06:48:39 +0000 (17:48 +1100)
char (which did not come from stdio read functions) in the presence of
ctype macros, is to always cast to (unsigned char).  casting to (int)
for a "macro" which is documented to take int, is weird.  And sadly wrong,
because of the sing extension risk.. same diff from florian

OpenBSD-Commit-ID: 65b9a49a68e22ff3a0ebd593f363e9f22dd73fea

misc.c

diff --git a/misc.c b/misc.c
index 977c097e233d82427f2692d80555c654f33348fc..41244da9c42c7a6795cec2480093c6fe7a70b8d7 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.178 2022/11/09 09:01:52 dtucker Exp $ */
+/* $OpenBSD: misc.c,v 1.179 2022/12/15 18:20:39 deraadt Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2005-2020 Damien Miller.  All rights reserved.
@@ -95,7 +95,7 @@ rtrim(char *s)
        if ((i = strlen(s)) == 0)
                return;
        for (i--; i > 0; i--) {
-               if (isspace((int)s[i]))
+               if (isspace((unsigned char)s[i]))
                        s[i] = '\0';
        }
 }