From 1186fcf9b95e6390335ca3a1fa16f5e53dbff412 Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 20 Jul 2014 06:39:41 +0000 Subject: [PATCH] Correctly cast to unsigned char for ctype functions/macros Push and into the .c files --- usr.bin/telnet/commands.c | 12 +++++++----- usr.bin/telnet/genget.c | 5 ++--- usr.bin/telnet/main.c | 7 ++----- usr.bin/telnet/sys_bsd.c | 4 +++- usr.bin/telnet/telnet.c | 8 +++++--- usr.bin/telnet/telnet_locl.h | 4 +--- usr.bin/telnet/utilities.c | 22 ++++++++++------------ 7 files changed, 30 insertions(+), 32 deletions(-) diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index d2eb50bf08e..5e0f6a90086 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.59 2014/07/20 05:22:02 guenther Exp $ */ +/* $OpenBSD: commands.c,v 1.60 2014/07/20 06:39:41 guenther Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -36,9 +36,11 @@ #include #include +#include #include #include #include +#include int tos = -1; @@ -108,7 +110,7 @@ makeargv() } while ((c = *cp)) { int inquote = 0; - while (isspace(c)) + while (isspace((unsigned char)c)) c = *++cp; if (c == '\0') break; @@ -130,7 +132,7 @@ makeargv() } else if (c == '\'') { inquote = '\''; continue; - } else if (isspace(c)) + } else if (isspace((unsigned char)c)) break; } *cp2++ = c; @@ -1842,11 +1844,11 @@ cmdrc(char *m1, char *m2) if (line[0] == '#') continue; if (gotmachine) { - if (!isspace(line[0])) + if (!isspace((unsigned char)line[0])) gotmachine = 0; } if (gotmachine == 0) { - if (isspace(line[0])) + if (isspace((unsigned char)line[0])) continue; if (strncasecmp(line, m1, l1) == 0) strncpy(line, &line[l1], sizeof(line) - l1); diff --git a/usr.bin/telnet/genget.c b/usr.bin/telnet/genget.c index 10ba23531b0..aaca4fb4d95 100644 --- a/usr.bin/telnet/genget.c +++ b/usr.bin/telnet/genget.c @@ -1,4 +1,4 @@ -/* $OpenBSD: genget.c,v 1.3 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: genget.c,v 1.4 2014/07/20 06:39:41 guenther Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -34,7 +34,6 @@ #include #include "telnet_locl.h" -#define LOWER(x) (isupper((int)x) ? tolower((int)x) : (x)) /* * The prefix function returns 0 if *s1 is not a prefix * of *s2. If *s1 exactly matches *s2, the negative of @@ -52,7 +51,7 @@ isprefix(char *s1, char *s2) os1 = s1; c1 = *s1; c2 = *s2; - while (LOWER(c1) == LOWER(c2)) { + while (tolower((unsigned char)c1) == tolower((unsigned char)c2)) { if (c1 == '\0') break; c1 = *++s1; diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index 9a22875c641..e4faa49d323 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.24 2014/07/20 05:22:02 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.25 2014/07/20 06:39:41 guenther Exp $ */ /* $NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $ */ /* @@ -32,10 +32,7 @@ #include "telnet_locl.h" -/* These values need to be the same as defined in libtelnet/kerberos5.c */ -/* Either define them in both places, or put in some common header file. */ -#define OPTS_FORWARD_CREDS 0x00000002 -#define OPTS_FORWARDABLE_CREDS 0x00000001 +#include int family = AF_UNSPEC; int rtableid = -1; diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index 034e7c3acfe..8d0d3c66736 100644 --- a/usr.bin/telnet/sys_bsd.c +++ b/usr.bin/telnet/sys_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_bsd.c,v 1.17 2014/07/20 05:22:02 guenther Exp $ */ +/* $OpenBSD: sys_bsd.c,v 1.18 2014/07/20 06:39:41 guenther Exp $ */ /* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */ /* @@ -31,8 +31,10 @@ */ #include "telnet_locl.h" + #include #include +#include /* * The following routines try to encapsulate what is system dependent diff --git a/usr.bin/telnet/telnet.c b/usr.bin/telnet/telnet.c index a4d765db027..4793180a814 100644 --- a/usr.bin/telnet/telnet.c +++ b/usr.bin/telnet/telnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: telnet.c,v 1.22 2014/07/20 03:00:31 deraadt Exp $ */ +/* $OpenBSD: telnet.c,v 1.23 2014/07/20 06:39:41 guenther Exp $ */ /* $NetBSD: telnet.c,v 1.7 1996/02/28 21:04:15 thorpej Exp $ */ /* @@ -31,6 +31,8 @@ */ #include "telnet_locl.h" + +#include #include #include @@ -528,8 +530,8 @@ mklist(buf, name) #define ISASCII(c) (!((c)&0x80)) if ((c == ' ') || !ISASCII(c)) n = 1; - else if (islower(c)) - *cp = toupper(c); + else + *cp = toupper((unsigned char)c); } /* diff --git a/usr.bin/telnet/telnet_locl.h b/usr.bin/telnet/telnet_locl.h index cc74ca215e7..1522ed46cc7 100644 --- a/usr.bin/telnet/telnet_locl.h +++ b/usr.bin/telnet/telnet_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: telnet_locl.h,v 1.6 2014/07/20 05:22:02 guenther Exp $ */ +/* $OpenBSD: telnet_locl.h,v 1.7 2014/07/20 06:39:41 guenther Exp $ */ /* $KTH: telnet_locl.h,v 1.13 1997/11/03 21:37:55 assar Exp $ */ /* @@ -42,7 +42,6 @@ #include #include -#include #include #include #include @@ -53,7 +52,6 @@ #include #include #include -#include #include diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c index 2879031226b..f04a21e70c0 100644 --- a/usr.bin/telnet/utilities.c +++ b/usr.bin/telnet/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.13 2014/07/20 05:22:02 guenther Exp $ */ +/* $OpenBSD: utilities.c,v 1.14 2014/07/20 06:39:41 guenther Exp $ */ /* $NetBSD: utilities.c,v 1.5 1996/02/28 21:04:21 thorpej Exp $ */ /* @@ -36,6 +36,8 @@ #define SLC_NAMES #include "telnet_locl.h" + +#include #include FILE *NetTrace = 0; /* Not in bss, since needs to stay */ @@ -47,18 +49,13 @@ int prettydump; * Upcase (in place) the argument. */ - void -upcase(argument) - char *argument; +void +upcase(char *argument) { - int c; + int c; - while ((c = *argument) != 0) { - if (islower(c)) { - *argument = toupper(c); - } - argument++; - } + while ((c = *argument) != '\0') + *argument++ = toupper((unsigned char)c); } /* @@ -610,7 +607,8 @@ printsub(direction, pointer, length) break; default: - if (isprint(pointer[i]) && pointer[i] != '"') { + if (isprint((unsigned char)pointer[i]) && + pointer[i] != '"') { if (noquote) { putc('"', NetTrace); noquote = 0; -- 2.20.1