[Bug 377] New: Reduce compiler warnings. Use unsigned args to the ctype.h is*() macros.
bugzilla-daemon at mindrot.org
bugzilla-daemon at mindrot.org
Fri Aug 2 22:37:36 EST 2002
http://bugzilla.mindrot.org/show_bug.cgi?id=377
Summary: Reduce compiler warnings. Use unsigned args to the
ctype.h is*() macros.
Product: Portable OpenSSH
Version: -current
Platform: Sparc
OS/Version: Solaris
Status: NEW
Severity: trivial
Priority: P2
Component: Miscellaneous
AssignedTo: openssh-unix-dev at mindrot.org
ReportedBy: mdb at juniper.net
On Solaris 8, using gcc 3.1, the following warnings are given during
build of OpenSSH from the -cvs sources:
canohost.c:93: warning: subscript has type `char'
clientloop.c:488: warning: subscript has type `char'
clientloop.c:503: warning: subscript has type `char'
inet_aton.c:117: warning: subscript has type `char'
inet_aton.c:128: warning: subscript has type `char'
inet_aton.c:131: warning: subscript has type `char'
inet_aton.c:133: warning: subscript has type `char'
inet_aton.c:155: warning: subscript has type `char'
match.c:138: warning: subscript has type `char'
mktemp.c:168: warning: subscript has type `char'
readpassphrase.c:123: warning: subscript has type `char'
scp.c:758: warning: subscript has type `char'
sshconnect.c:834: warning: subscript has type `char'
Given the possibility of characters outside of the 0 thru 0x7f range
and the implementation of the is*() macros as using an index into an
array, negative arguments could lead to unexpected behavior.
log:
* canohost.c (get_remote_hostname): Argument to macro
isupper() should be unsigned.
* clientloop.c (process_cmdlin): Argument to macro isspace()
should be unsigned.
* match.c (match_pattern_list): Argument to macro isupper()
should be unsigned.
* scp.c (sink): Argument to macro isdigit() should be unsigned.
* sshconnect.c (ssh_login): Argument to macro isupper() should
be unsigned.
* openbsd-compat/inet_aton.c (inet_aton): Arguments to
the isdigit(), isxdigit(), islower() and isspace() macros
should be unsigned.
* openbsd-compat/mktemp.c (_gettemp): The isdigit() macro
argument should be unsigned.
* openbsd-compat/readpassphrase.c (readpassphrase): The
isalpha() macro argument should be unsigned.
Index: canohost.c
===================================================================
RCS file: /cvs/openssh/canohost.c,v
retrieving revision 1.30
diff -u -p -r1.30 canohost.c
--- canohost.c 11 Jul 2002 03:56:47 -0000 1.30
+++ canohost.c 2 Aug 2002 12:13:37 -0000
@@ -90,7 +90,7 @@ get_remote_hostname(int socket, int veri
* of this software).
*/
for (i = 0; name[i]; i++)
-
if (isupper(name[i]))
+
if (isupper((unsigned)name[i]))
name[i] = tolower(name[i]);
if (!verify_reverse_mapping)
Index: clientloop.c
===================================================================
RCS file: /cvs/openssh/clientloop.c,v
retrieving revision 1.87
diff -u -p -r1.87 clientloop.c
--- clientloop.c 4 Jul 2002 00:14:18 -0000 1.87
+++ clientloop.c 2 Aug 2002 12:13:38 -0000
@@ -485,7 +485,7 @@ process_cmdline(void)
cmd = s = read_passphrase("\r\nssh> ", RP_ECHO);
if (s == NULL)
goto out;
-
while (*s && isspace(*s))
+
while (*s && isspace((unsigned)*s))
s++;
if (*s == 0)
goto out;
@@ -500,7 +500,7 @@ process_cmdline(void)
goto out;
}
s += 2;
-
while (*s && isspace(*s))
+
while (*s && isspace((unsigned)*s))
s++;
if (sscanf(s, "%5[0-9]:%255[^:]:%5[0-9]",
Index: match.c
===================================================================
RCS file: /cvs/openssh/match.c,v
retrieving revision 1.18
diff -u -p -r1.18 match.c
--- match.c 5 Mar 2002 01:42:43 -0000 1.18
+++ match.c 2 Aug 2002 12:13:39 -0000
@@ -135,7 +135,7 @@ match_pattern_list(const char *string, c
for (subi = 0;
i < len && subi < sizeof(sub) - 1 && pattern[i] != ',';
subi++, i++)
-
sub[subi] = dolower && isupper(pattern[i]) ?
+
sub[subi] = dolower && isupper((unsigned)pattern[i]) ?
tolower(pattern[i]) : pattern[i];
/* If subpattern too long, return failure (no match). */
if (subi >= sizeof(sub) - 1)
Index: scp.c
===================================================================
RCS file: /cvs/openssh/scp.c,v
retrieving revision 1.97
diff -u -p -r1.97 scp.c
--- scp.c 21 Jun 2002 00:41:52 -0000 1.97
+++ scp.c 2 Aug 2002 12:13:43 -0000
@@ -755,7 +755,7 @@ sink(argc, argv)
if (*cp++ != ' ')
SCREWUP("mode not delimited");
-
for (size = 0; isdigit(*cp);)
+
for (size = 0; isdigit((unsigned)*cp);)
size = size * 10 + (*cp++ - '0');
if (*cp++ != ' ')
SCREWUP("size not delimited");
Index: sshconnect.c
===================================================================
RCS file: /cvs/openssh/sshconnect.c,v
retrieving revision 1.99
diff -u -p -r1.99 sshconnect.c
--- sshconnect.c 1 Aug 2002 01:26:30 -0000 1.99
+++ sshconnect.c 2 Aug 2002 12:13:44 -0000
@@ -831,7 +831,7 @@ ssh_login(Sensitive *sensitive, const ch
/* Convert the user-supplied hostname into all lowercase. */
host = xstrdup(orighost);
for (cp = host; *cp; cp++)
-
if (isupper(*cp))
+
if (isupper((unsigned)*cp))
*cp = tolower(*cp);
/* Exchange protocol version identification strings with the server. */
Index: openbsd-compat/inet_aton.c
===================================================================
RCS file: /cvs/openssh/openbsd-compat/inet_aton.c,v
retrieving revision 1.4
diff -u -p -r1.4 inet_aton.c
--- openbsd-compat/inet_aton.c 12 Apr 2002 03:35:40 -0000 1.4
+++ openbsd-compat/inet_aton.c 2 Aug 2002 12:13:44 -0000
@@ -103,7 +103,7 @@ inet_aton(const char *cp, struct in_addr
{
register u_int32_t val;
register int base, n;
-
register char c;
+
register unsigned char c;
unsigned int parts[4];
register unsigned int *pp = parts;
Index: openbsd-compat/mktemp.c
===================================================================
RCS file: /cvs/openssh/openbsd-compat/mktemp.c,v
retrieving revision 1.2
diff -u -p -r1.2 mktemp.c
--- openbsd-compat/mktemp.c 13 Feb 2002 05:00:16 -0000 1.2
+++ openbsd-compat/mktemp.c 2 Aug 2002 12:13:44 -0000
@@ -165,7 +165,7 @@ _gettemp(path, doopen, domkdir, slen)
return (0);
*trv++ = 'a';
} else {
-
if (isdigit(*trv))
+
if (isdigit((unsigned)*trv))
*trv = 'a';
else if (*trv == 'z') /* inc from z to A */
*trv = 'A';
Index: openbsd-compat/readpassphrase.c
===================================================================
RCS file: /cvs/openssh/openbsd-compat/readpassphrase.c,v
retrieving revision 1.8
diff -u -p -r1.8 readpassphrase.c
--- openbsd-compat/readpassphrase.c 1 May 2002 12:00:22 -0000 1.8
+++ openbsd-compat/readpassphrase.c 2 Aug 2002 12:13:44 -0000
@@ -120,7 +120,7 @@ restart:
if (p < end) {
if ((flags & RPP_SEVENBIT))
ch &= 0x7f;
-
if (isalpha(ch)) {
+
if (isalpha((unsigned)ch)) {
if ((flags & RPP_FORCELOWER))
ch = tolower(ch);
if ((flags & RPP_FORCEUPPER))
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the openssh-unix-dev
mailing list