The various character predicates (isspace and the like) may not be
authorBodo Möller <bodo@openssl.org>
Mon, 10 May 1999 11:18:26 +0000 (11:18 +0000)
committerBodo Möller <bodo@openssl.org>
Mon, 10 May 1999 11:18:26 +0000 (11:18 +0000)
used with negative char values, so I've added casts to unsigned char.
Maybe what really should be done is change all those arrays and
pointers to type unsigned char [] or unsigned char *, respectively;
but using plain char with those predicates is just wrong, so something
had to be done.
Submitted by:
Reviewed by:
PR:

crypto/bn/bn_print.c
crypto/objects/obj_dat.c
crypto/x509v3/v3_conf.c
crypto/x509v3/v3_utl.c

index 1ec49ed3ccc84e76b0f3bfb18fca65d65400f0c0..f2d2fce58955ef9d568dfb742d1bef24de56fb58 100644 (file)
@@ -165,7 +165,7 @@ int BN_hex2bn(BIGNUM **bn, char *a)
 
        if (*a == '-') { neg=1; a++; }
 
-       for (i=0; isxdigit(a[i]); i++)
+       for (i=0; isxdigit((unsigned char) a[i]); i++)
                ;
 
        num=i+neg;
@@ -230,7 +230,7 @@ int BN_dec2bn(BIGNUM **bn, char *a)
        if ((a == NULL) || (*a == '\0')) return(0);
        if (*a == '-') { neg=1; a++; }
 
-       for (i=0; isdigit(a[i]); i++)
+       for (i=0; isdigit((unsigned char) a[i]); i++)
                ;
 
        num=i+neg;
index cfc082add33ef0f1f422376aef3a4467ddb400a5..0b24b144460f807d5942df6a620490c617c991ea 100644 (file)
@@ -512,26 +512,26 @@ int OBJ_create_objects(BIO *in)
                i=BIO_gets(in,buf,512);
                if (i <= 0) return(num);
                buf[i-1]='\0';
-               if (!isalnum(buf[0])) return(num);
+               if (!isalnum((unsigned char)buf[0])) return(num);
                o=s=buf;
-               while (isdigit(*s) || (*s == '.'))
+               while (isdigit((unsigned char)*s) || (*s == '.'))
                        s++;
                if (*s != '\0')
                        {
                        *(s++)='\0';
-                       while (isspace(*s))
+                       while (isspace((unsigned char)*s))
                                s++;
                        if (*s == '\0')
                                s=NULL;
                        else
                                {
                                l=s;
-                               while ((*l != '\0') && !isspace(*l))
+                               while ((*l != '\0') && !isspace((unsigned char)*l))
                                        l++;
                                if (*l != '\0')
                                        {
                                        *(l++)='\0';
-                                       while (isspace(*l))
+                                       while (isspace((unsigned char)*l))
                                                l++;
                                        if (*l == '\0') l=NULL;
                                        }
index 0460fbedfc6529f93e160a962d2c368bf6b30b12..91cc7ebfaa65c09d5ac848517d8489c71de4d35b 100644 (file)
@@ -203,7 +203,7 @@ static int v3_check_critical(char **value)
        char *p = *value;
        if((strlen(p) < 9) || strncmp(p, "critical,", 9)) return 0;
        p+=9;
-       while(isspace(*p)) p++;
+       while(isspace((unsigned char)*p)) p++;
        *value = p;
        return 1;
 }
@@ -214,7 +214,7 @@ static int v3_check_generic(char **value)
        char *p = *value;
        if((strlen(p) < 4) || strncmp(p, "RAW:,", 4)) return 0;
        p+=4;
-       while(isspace(*p)) p++;
+       while(isspace((unsigned char)*p)) p++;
        *value = p;
        return 1;
 }
index c1ea05c1e91fe282ec0765d6066d8af21db21e56..7ffab1383c70750b7900d31c54b5a40b9c91bce1 100644 (file)
@@ -311,10 +311,10 @@ static char *strip_spaces(char *name)
        char *p, *q;
        /* Skip over leading spaces */
        p = name;
-       while(*p && isspace(*p)) p++;
+       while(*p && isspace((unsigned char)*p)) p++;
        if(!*p) return NULL;
        q = p + strlen(p) - 1;
-       while((q != p) && isspace(*q)) q--;
+       while((q != p) && isspace((unsigned char)*q)) q--;
        if(p != q) q[1] = 0;
        if(!*p) return NULL;
        return p;