Commit 709ce4fa authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Re: Patch: ctype functions require 'unsigned char' args (ITS#1678)

			================
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.
parent 15fffeda
......@@ -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 ) {
......
......@@ -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;
}
}
......
......@@ -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 ] = '.';
......
......@@ -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 {
......
......@@ -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' ) {
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment