]> git.sur5r.net Git - openldap/commitdiff
Re: Patch: ctype functions require 'unsigned char' args (ITS#1678)
authorKurt Zeilenga <kurt@openldap.org>
Mon, 15 Apr 2002 20:42:42 +0000 (20:42 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 15 Apr 2002 20:42:42 +0000 (20:42 +0000)
================
Written by Hallvard B. Furuseth and placed into the public domain.
This software is not subject to any license of the University of Oslo.
================

Here are fixes for more places where the argument to ctype.h functions
should be in the range of `unsigned char'.

Explanation of the last patch (to schema_init.c:bvcasechr()):
TOLOWER() and TOUPPER() return values in the range of `unsigned char',
but bvcasechr() then compares those values with a plain `char'.  So I
convert the return values from TOLOWER()/TOUPPER() to `char' first.

Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>, April 2002.

clients/maildap/main.c
clients/tools/ldapmodify.c
libraries/liblber/bprint.c
libraries/libldap/cyrus.c
servers/slapd/aclparse.c
servers/slapd/back-passwd/search.c
servers/slapd/back-sql/util.c
servers/slapd/config.c
servers/slapd/referral.c
servers/slapd/schema_init.c

index f8fd75177937db816f1880d987099e558229dbe4..345c8f4256853b9cc02df766d1e89b3cd15ea8d8 100644 (file)
@@ -419,9 +419,9 @@ get_config_line( FILE *cf, int *lineno)
                (*lineno)++;
                if ( pos > 0 ) {
                        /* Delete whitespace at the beginning of new data */
-                       if ( isspace( buf[pos] ) ) {
+                       if ( isspace( (unsigned char) buf[pos] ) ) {
                                char *s, *d;
-                               for ( s = buf+pos; isspace(*s); s++ )
+                               for ( s = buf+pos; isspace((unsigned char) *s); s++ )
                                        ;
                                for ( d = buf+pos; *s; s++, d++ ) {
                                        *d = *s;
@@ -518,20 +518,20 @@ add_attr_semantics( char *s )
        as = calloc( 1, sizeof( AttrSemantics ) );
        as->as_priority = current_priority;
        p = s;
-       while ( isspace ( *p ) )
+       while ( isspace ( (unsigned char) *p ) )
                p++;
        q = p;
-       while ( !isspace ( *q ) && *q != '\0' )
+       while ( !isspace ( (unsigned char) *q ) && *q != '\0' )
                q++;
        *q = '\0';
        as->as_name = strdup( p );
        p = q + 1;
 
        while ( *p ) {
-               while ( isspace ( *p ) )
+               while ( isspace ( (unsigned char) *p ) )
                        p++;
                q = p;
-               while ( !isspace ( *q ) && *q != '\0' )
+               while ( !isspace ( (unsigned char) *q ) && *q != '\0' )
                        q++;
                *q = '\0';
                if ( !strcasecmp( p, "multivalued" ) ) {
@@ -554,7 +554,7 @@ add_attr_semantics( char *s )
                        q = strchr( p, '=' );
                        if ( q ) {
                                p = q + 1;
-                               while ( *q && !isspace( *q ) ) {
+                               while ( *q && !isspace( (unsigned char) *q ) ) {
                                        q++;
                                }
                                if ( *q ) {
index 8db5c817760aafee1e1fef3984dd0349e437c8ea..f55cb80aa15d2bc2bf83bfc057d768979e58e4b8 100644 (file)
@@ -812,7 +812,7 @@ process_ldif_rec( char *rbuf, int count )
 
                int icnt;
                for ( icnt = val.bv_len; --icnt > 0; ) {
-                   if ( !isspace( val.bv_val[icnt] ) ) {
+                   if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) {
                        break;
                    }
                }
@@ -857,7 +857,7 @@ process_ldif_rec( char *rbuf, int count )
            
            int icnt;
            for ( icnt = val.bv_len; --icnt > 0; ) {
-               if ( !isspace( val.bv_val[icnt] ) ) {
+               if ( !isspace( (unsigned char) val.bv_val[icnt] ) ) {
                    break;
                }
            }
index a6ae8ce7ed68337196edc622c1382071d440ba36..23ebf88853e05261216084530eb2f2a0e4ebdffd 100644 (file)
@@ -285,7 +285,7 @@ int ber_output_dump(
         
         off = BP_GRAPH + n + ((n >= 8)?1:0);
         
-        if ( isprint( data[i] )) {
+        if ( isprint( (unsigned char) data[i] )) {
             line[ BP_GRAPH + n ] = data[i];
         } else {
             line[ BP_GRAPH + n ] = '.';
index 5f128098d353f079f95da282ee06beb5c46ecb95..d14e893c058357e21e0bffac8a99350001a696cc 100644 (file)
@@ -846,7 +846,7 @@ int ldap_pvt_sasl_secprops(
                } else if( !strncasecmp(props[i],
                        "minssf=", sizeof("minssf")) )
                {
-                       if( isdigit( props[i][sizeof("minssf")] ) ) {
+                       if( isdigit( (unsigned char) props[i][sizeof("minssf")] ) ) {
                                got_min_ssf++;
                                min_ssf = atoi( &props[i][sizeof("minssf")] );
                        } else {
@@ -856,7 +856,7 @@ int ldap_pvt_sasl_secprops(
                } else if( !strncasecmp(props[i],
                        "maxssf=", sizeof("maxssf")) )
                {
-                       if( isdigit( props[i][sizeof("maxssf")] ) ) {
+                       if( isdigit( (unsigned char) props[i][sizeof("maxssf")] ) ) {
                                got_max_ssf++;
                                max_ssf = atoi( &props[i][sizeof("maxssf")] );
                        } else {
@@ -866,7 +866,7 @@ int ldap_pvt_sasl_secprops(
                } else if( !strncasecmp(props[i],
                        "maxbufsize=", sizeof("maxbufsize")) )
                {
-                       if( isdigit( props[i][sizeof("maxbufsize")] ) ) {
+                       if( isdigit( (unsigned char) props[i][sizeof("maxbufsize")] ) ) {
                                got_maxbufsize++;
                                maxbufsize = atoi( &props[i][sizeof("maxbufsize")] );
                        } else {
index 95397c2668eb71b7d04639b4e679df4f75d082bc..1c8a5bad379e7ed8dff112897c69985f08c88e75 100644 (file)
@@ -1191,19 +1191,19 @@ str2accessmask( const char *str )
                }
 
                for( i=1; str[i] != '\0'; i++ ) {
-                       if( TOLOWER(str[i]) == 'w' ) {
+                       if( TOLOWER((unsigned char) str[i]) == 'w' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_WRITE);
 
-                       } else if( TOLOWER(str[i]) == 'r' ) {
+                       } else if( TOLOWER((unsigned char) str[i]) == 'r' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_READ);
 
-                       } else if( TOLOWER(str[i]) == 's' ) {
+                       } else if( TOLOWER((unsigned char) str[i]) == 's' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_SEARCH);
 
-                       } else if( TOLOWER(str[i]) == 'c' ) {
+                       } else if( TOLOWER((unsigned char) str[i]) == 'c' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_COMPARE);
 
-                       } else if( TOLOWER(str[i]) == 'x' ) {
+                       } else if( TOLOWER((unsigned char) str[i]) == 'x' ) {
                                ACL_PRIV_SET(mask, ACL_PRIV_AUTH);
 
                        } else if( str[i] != '0' ) {
index 2cdeb4c9cf1671c2b1566d3a70f98805ebee3e1f..83db8ae5fea8d83d801f597dda78ab2e0aa9b024 100644 (file)
@@ -325,7 +325,7 @@ pw2entry( Backend *be, struct passwd *pw, const char **text )
                        strncpy(buf, vals[0].bv_val, i);
                        s = buf+i;
                        strcpy(s, pw->pw_name);
-                       *s = TOUPPER(*s);
+                       *s = TOUPPER((unsigned char)*s);
                        strcat(s, vals[0].bv_val+i+1);
                        vals[0].bv_val = buf;
                }
index fcb1254db271e5a4bfb14de6fe4c0faddee61890..00e1d33889e6ffce2c509c180d20e50216abfcba 100644 (file)
@@ -115,7 +115,14 @@ char* backsql_get_table_spec(char **p)
  if (**p)
   *(*p)++='\0';
 
-#define BACKSQL_NEXT_WORD  {while (*s && isspace(*s)) s++; if (!*s) return res; q=s; while (*q && !isspace(*q)) q++; if (*q) *q++='\0';}
+#define BACKSQL_NEXT_WORD { \
+  while (*s && isspace((unsigned char)*s)) s++; \
+  if (!*s) return res; \
+  q=s; \
+  while (*q && !isspace((unsigned char)*q)) q++; \
+  if (*q) *q++='\0'; \
+ }
+
  BACKSQL_NEXT_WORD;
  res=backsql_strcat(res,&res_len,s,NULL);/*table name*/
  s=q;
index 06016c0a7692d8d1ef159192d59cd77bb6d1acdf..286531681413c5b69ba5a3756f1fe10b90dfa8ef 100644 (file)
@@ -2222,7 +2222,7 @@ read_config( const char *fname )
                        if ( rc )
                                return rc;
                } else if ( !strcasecmp( cargv[0], "TLSVerifyClient" ) ) {
-                       if ( isdigit( cargv[1][0] ) ) {
+                       if ( isdigit( (unsigned char) cargv[1][0] ) ) {
                                i = atoi(cargv[1]);
                                rc = ldap_pvt_tls_set_option( NULL,
                                                      LDAP_OPT_X_TLS_REQUIRE_CERT,
index d3caa3ffd4a0c39c767160ae4fc48ea1f04d1a92..53edf251fba585d36abccdac5f419b604b499240 100644 (file)
@@ -314,7 +314,7 @@ BerVarray get_entry_referrals(
 
                /* trim the label */
                for( k=0; k<jv->bv_len; k++ ) {
-                       if( isspace(jv->bv_val[k]) ) {
+                       if( isspace( (unsigned char) jv->bv_val[k] ) ) {
                                jv->bv_val[k] = '\0';
                                jv->bv_len = k;
                                break;
index 8695cd8fe63855189fc1f100c9bf0ab59143a48e..fb82f181b35ebb3b7b97b09f5c5fa819080d48c0 100644 (file)
@@ -98,11 +98,11 @@ static const struct MatchingRulePtr {
 };
 
 
-static char *bvcasechr( struct berval *bv, int c, ber_len_t *len )
+static char *bvcasechr( struct berval *bv, unsigned char c, ber_len_t *len )
 {
        ber_len_t i;
-       int lower = TOLOWER( c );
-       int upper = TOUPPER( c );
+       char lower = TOLOWER( c );
+       char upper = TOUPPER( c );
 
        if( c == 0 ) return NULL;