[Bug 377] New: Reduce compiler warnings. Use unsigned args to the ctype.h is*() macros.
Mark D. Baushke
mdb at juniper.net
Sat Aug 3 09:12:05 EST 2002
Ben Lindstrom wrote:
>Umm.. why not just change 'char name[..];' to u_char name[..]? Fix the
>issue at the source instead of candy coating them?
Done.
>The same with the rest?
Both scp.c and mktemp.c have other functions that want pointers to char
rather than u_char passed as args. Hacking them to use u_char buffers
makes gcc 3.1 complain about more lines. I think the cast is the better
approach with those two files. I am using u_char types for the others.
-- Mark
Log:
2002-08-02 Mark D Baushke <mdb at juniper.net>
* canonhost.c, clientloop.c, match.c, match.h, scp.c,
sshconnect.c, openbsd-compat/inet_aton.c,
openbsd-compat/mktemp.c, openbsd-compat/readpassphrase.c:
Avoid problems on hosts with signed chars potentially passing a
non-EOF negative value to the ctype.h is* functions. Use u_char
for the variables where possible or cast to u_char if needed.
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 23:02:02 -0000
@@ -33,7 +33,8 @@ get_remote_hostname(int socket, int veri
int i;
socklen_t fromlen;
struct addrinfo hints, *ai, *aitop;
- char name[NI_MAXHOST], ntop[NI_MAXHOST], ntop2[NI_MAXHOST];
+ u_char name[NI_MAXHOST];
+ char ntop[NI_MAXHOST], ntop2[NI_MAXHOST];
/* Get IP address of client. */
fromlen = sizeof(from);
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 23:02:03 -0000
@@ -475,7 +475,7 @@ static void
process_cmdline(void)
{
void (*handler)(int);
- char *s, *cmd;
+ u_char *s, *cmd;
u_short fwd_port, fwd_host_port;
char buf[1024], sfwd_port[6], sfwd_host_port[6];
int local = 0;
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 23:02:03 -0000
@@ -111,10 +111,10 @@ match_pattern(const char *s, const char
*/
int
-match_pattern_list(const char *string, const char *pattern, u_int len,
- int dolower)
+match_pattern_list(const u_char *string, const u_char *pattern,
+ u_int len, int dolower)
{
- char sub[1024];
+ u_char sub[1024];
int negated;
int got_positive;
u_int i, subi;
Index: match.h
===================================================================
RCS file: /cvs/openssh/match.h,v
retrieving revision 1.11
diff -u -p -r1.11 match.h
--- match.h 5 Mar 2002 01:42:43 -0000 1.11
+++ match.h 2 Aug 2002 23:02:03 -0000
@@ -15,7 +15,7 @@
#define MATCH_H
int match_pattern(const char *, const char *);
-int match_pattern_list(const char *, const char *, u_int, int);
+int match_pattern_list(const u_char *, const u_char *, u_int, int);
int match_hostname(const char *, const char *, u_int);
int match_host_and_ip(const char *, const char *, const char *);
int match_user(const char *, const char *, const char *, const char *);
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 23:02:04 -0000
@@ -755,7 +755,7 @@ sink(argc, argv)
if (*cp++ != ' ')
SCREWUP("mode not delimited");
- for (size = 0; isdigit(*cp);)
+ for (size = 0; isdigit((u_char) *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 23:02:04 -0000
@@ -822,7 +822,7 @@ void
ssh_login(Sensitive *sensitive, const char *orighost,
struct sockaddr *hostaddr, struct passwd *pw)
{
- char *host, *cp;
+ u_char *host, *cp;
char *server_user, *local_user;
local_user = xstrdup(pw->pw_name);
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 23:02:05 -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 u_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 23:02:05 -0000
@@ -165,7 +165,7 @@ _gettemp(path, doopen, domkdir, slen)
return (0);
*trv++ = 'a';
} else {
- if (isdigit(*trv))
+ if (isdigit((u_char)*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 23:02:05 -0000
@@ -58,7 +58,8 @@ readpassphrase(const char *prompt, char
{
ssize_t nr;
int input, output, save_errno;
- char ch, *p, *end;
+ char *p, *end;
+ u_char ch;
struct termios term, oterm;
struct sigaction sa, saveint, savehup, savequit, saveterm;
struct sigaction savetstp, savettin, savettou;
More information about the openssh-unix-dev
mailing list