From 0cac95ff79f6cc5d21bc85d76e91615c50228ee9 Mon Sep 17 00:00:00 2001
From: Ken Raeburn <raeburn@mit.edu>
Date: Fri, 16 Jun 2006 06:58:42 +0000
Subject: [PATCH] Change a bunch of calls to ctype macros (those cited by Jeff,
 and a few others) to cast the character values to unsigned char.

ticket: 3445

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18156 dc483132-0cff-0310-8789-dd5450dbe970
---
 src/appl/gssftp/ftp/cmds.c      | 12 ++++++------
 src/appl/telnet/telnet/telnet.c |  4 ++--
 src/lib/kadm5/srv/server_acl.c  |  2 +-
 src/lib/kadm5/srv/server_misc.c |  8 ++++----
 src/lib/krb4/kparse.c           |  4 ++--
 src/lib/krb5/ccache/ccbase.c    |  2 +-
 src/lib/krb5/keytab/ktbase.c    |  2 +-
 src/lib/krb5/krb/conv_princ.c   |  4 ++--
 src/lib/krb5/os/hst_realm.c     |  8 ++++----
 src/lib/krb5/os/sn2princ.c      |  4 ++--
 src/tests/asn.1/utility.c       |  4 ++--
 11 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/appl/gssftp/ftp/cmds.c b/src/appl/gssftp/ftp/cmds.c
index b9cb2a2a2..3d851937b 100644
--- a/src/appl/gssftp/ftp/cmds.c
+++ b/src/appl/gssftp/ftp/cmds.c
@@ -725,14 +725,14 @@ void mput(argc, argv)
 			if (mflag && confirm(argv[0], cp)) {
 				tp = cp;
 				if (mcase) {
-					while (*tp && !islower((int) (*tp))) {
+					while (*tp && !islower((unsigned char) (*tp))) {
 						tp++;
 					}
 					if (!*tp) {
 						tp = cp;
 						tp2 = tmpbuf;
 						while ((*tp2 = *tp) != 0) {
-						     if (isupper((int) *tp2)) {
+						     if (isupper((unsigned char) *tp2)) {
 						        *tp2 = 'a' + *tp2 - 'A';
 						     }
 						     tp++;
@@ -864,14 +864,14 @@ usage:
 	if (loc && mcase) {
 		char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN];
 
-		while (*tp && !islower((int) *tp)) {
+		while (*tp && !islower((unsigned char) *tp)) {
 			tp++;
 		}
 		if (!*tp) {
 			tp = argv[2];
 			tp2 = tmpbuf;
 			while ((*tp2 = *tp) != 0) {
-				if (isupper((int) *tp2)) {
+				if (isupper((unsigned char) *tp2)) {
 					*tp2 = 'a' + *tp2 - 'A';
 				}
 				tp++;
@@ -994,14 +994,14 @@ void mget(argc, argv)
 		if (mflag && confirm(argv[0], cp)) {
 			tp = cp;
 			if (mcase) {
-				while (*tp && !islower((int) *tp)) {
+				while (*tp && !islower((unsigned char) *tp)) {
 					tp++;
 				}
 				if (!*tp) {
 					tp = cp;
 					tp2 = tmpbuf;
 					while ((*tp2 = *tp) != 0) {
-						if (isupper((int) *tp2)) {
+						if (isupper((unsigned char) *tp2)) {
 							*tp2 = 'a' + *tp2 - 'A';
 						}
 						tp++;
diff --git a/src/appl/telnet/telnet/telnet.c b/src/appl/telnet/telnet/telnet.c
index 6215fc1e9..a44df7ab5 100644
--- a/src/appl/telnet/telnet/telnet.c
+++ b/src/appl/telnet/telnet/telnet.c
@@ -717,8 +717,8 @@ mklist(buf, name)
 		 */
 		if ((c == ' ') || !isascii(c))
 			n = 1;
-		else if (islower((int) c))
-			*cp = toupper((int) c);
+		else if (islower((unsigned char) c))
+			*cp = toupper((unsigned char) c);
 	}
 	
 	/*
diff --git a/src/lib/kadm5/srv/server_acl.c b/src/lib/kadm5/srv/server_acl.c
index fa63027f7..6d8d6d7f6 100644
--- a/src/lib/kadm5/srv/server_acl.c
+++ b/src/lib/kadm5/srv/server_acl.c
@@ -197,7 +197,7 @@ kadm5int_acl_parse_line(lp)
 	    for (op=acle_ops; *op; op++) {
 		char rop;
 
-		rop = (isupper((int) *op)) ? tolower((int) *op) : *op;
+		rop = (isupper((unsigned char) *op)) ? tolower((unsigned char) *op) : *op;
 		found = 0;
 		for (t=0; acl_op_table[t].ao_op; t++) {
 		    if (rop == acl_op_table[t].ao_op) {
diff --git a/src/lib/kadm5/srv/server_misc.c b/src/lib/kadm5/srv/server_misc.c
index fa4e62ee4..cd65371c9 100644
--- a/src/lib/kadm5/srv/server_misc.c
+++ b/src/lib/kadm5/srv/server_misc.c
@@ -134,17 +134,17 @@ passwd_check(kadm5_server_handle_t handle,
 	    return KADM5_PASS_Q_TOOSHORT;
 	s = password;
 	while ((c = *s++)) {
-	    if (islower((int) c)) {
+	    if (islower((unsigned char) c)) {
 		nlower = 1;
 		continue;
 	    }
-	    else if (isupper((int) c)) {
+	    else if (isupper((unsigned char) c)) {
 		nupper = 1;
 		continue;
-	    } else if (isdigit((int) c)) {
+	    } else if (isdigit((unsigned char) c)) {
 		ndigit = 1;
 		continue;
-	    } else if (ispunct((int) c)) {
+	    } else if (ispunct((unsigned char) c)) {
 		npunct = 1;
 		continue;
 	    } else {
diff --git a/src/lib/krb4/kparse.c b/src/lib/krb4/kparse.c
index 190518ad9..f6607a9ca 100644
--- a/src/lib/krb4/kparse.c
+++ b/src/lib/krb4/kparse.c
@@ -563,8 +563,8 @@ static char * strutol( start )
 {
     char *q;
     for (q=start; *q; q++)
-        if (isupper((int) *q))
-	    *q=tolower((int) *q);
+        if (isupper((unsigned char) *q))
+	    *q=tolower((unsigned char) *q);
     return(start);
 }
 
diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c
index 2b15ff6f3..df63e259d 100644
--- a/src/lib/krb5/ccache/ccbase.c
+++ b/src/lib/krb5/ccache/ccbase.c
@@ -151,7 +151,7 @@ krb5_cc_resolve (krb5_context context, const char *name, krb5_ccache *cache)
 
     pfxlen = cp - name;
 
-    if ( pfxlen == 1 && isalpha(name[0]) ) {
+    if ( pfxlen == 1 && isalpha((unsigned char) name[0]) ) {
         /* We found a drive letter not a prefix - use FILE: */
         pfx = strdup("FILE:");
         if (!pfx)
diff --git a/src/lib/krb5/keytab/ktbase.c b/src/lib/krb5/keytab/ktbase.c
index e633c0c3a..8374e6546 100644
--- a/src/lib/krb5/keytab/ktbase.c
+++ b/src/lib/krb5/keytab/ktbase.c
@@ -131,7 +131,7 @@ krb5_kt_resolve (krb5_context context, const char *name, krb5_keytab *ktid)
 
     pfxlen = cp - name;
 
-    if ( pfxlen == 1 && isalpha(name[0]) ) {
+    if ( pfxlen == 1 && isalpha((unsigned char) name[0]) ) {
         /* We found a drive letter not a prefix - use FILE: */
         pfx = strdup("FILE:");
         if (!pfx)
diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c
index 885dc995a..67768835f 100644
--- a/src/lib/krb5/krb/conv_princ.c
+++ b/src/lib/krb5/krb/conv_princ.c
@@ -329,8 +329,8 @@ krb5_425_conv_principal(krb5_context context, const char *name, const char *inst
 		      return retval;
 		  if (domain) {
 		      for (cp = domain; *cp; cp++)
-			  if (isupper((int) (*cp)))
-			      *cp = tolower((int) *cp);
+			  if (isupper((unsigned char) (*cp)))
+			      *cp = tolower((unsigned char) *cp);
 		      strncat(buf, ".", sizeof(buf) - 1 - strlen(buf));
 		      strncat(buf, domain, sizeof(buf) - 1 - strlen(buf));
 		      krb5_xfree(domain);
diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c
index b5c8f66ff..17b1e42c4 100644
--- a/src/lib/krb5/os/hst_realm.c
+++ b/src/lib/krb5/os/hst_realm.c
@@ -235,8 +235,8 @@ krb5_get_host_realm(krb5_context context, const char *host, char ***realmsp)
     }
 
     for (cp = local_host; *cp; cp++) {
-	if (isupper((int) (*cp)))
-	    *cp = tolower((int) *cp);
+	if (isupper((unsigned char) (*cp)))
+	    *cp = tolower((unsigned char) *cp);
     }
     l = strlen(local_host);
     /* strip off trailing dot */
@@ -318,8 +318,8 @@ krb5_get_host_realm(krb5_context context, const char *host, char ***realmsp)
 
             /* Assume the realm name is upper case */
             for (cp = realm; *cp; cp++)
-                if (islower((int) (*cp)))
-                    *cp = toupper((int) *cp);
+                if (islower((unsigned char) (*cp)))
+                    *cp = toupper((unsigned char) *cp);
         } else {    
             /* We are defaulting to the local realm */
             retval = krb5_get_default_realm(context, &realm);
diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c
index 65678c829..2ba7e8ae2 100644
--- a/src/lib/krb5/os/sn2princ.c
+++ b/src/lib/krb5/os/sn2princ.c
@@ -148,8 +148,8 @@ krb5_sname_to_principal(krb5_context context, const char *hostname, const char *
 
 	if (type == KRB5_NT_SRV_HST)
 	    for (cp = remote_host; *cp; cp++)
-		if (isupper((int) (*cp)))
-		    *cp = tolower((int) (*cp));
+		if (isupper((unsigned char) (*cp)))
+		    *cp = tolower((unsigned char) (*cp));
 
 	/*
 	 * Windows NT5's broken resolver gratuitously tacks on a
diff --git a/src/tests/asn.1/utility.c b/src/tests/asn.1/utility.c
index 660161fa1..6ad2e9de8 100644
--- a/src/tests/asn.1/utility.c
+++ b/src/tests/asn.1/utility.c
@@ -77,9 +77,9 @@ krb5_error_code krb5_data_hex_parse(krb5_data *d, const char *s)
     for (lo = 0, dp = d->data, cp = s; *cp; cp++) {
 	if (*cp < 0)
 	    return ASN1_PARSE_ERROR;
-	else if (isspace(*cp))
+	else if (isspace((unsigned char) *cp))
 	    continue;
-	else if (isxdigit(*cp)) {
+	else if (isxdigit((unsigned char) *cp)) {
 	    buf[0] = *cp;
 	    v = strtol(buf, NULL, 16);
 	} else
-- 
2.26.2