cryptlib.c: allow for OPENSSL_ia32cap=~0x????? syntax for environment value
authorAndy Polyakov <appro@openssl.org>
Fri, 9 Dec 2011 15:46:41 +0000 (15:46 +0000)
committerAndy Polyakov <appro@openssl.org>
Fri, 9 Dec 2011 15:46:41 +0000 (15:46 +0000)
in question.

crypto/cryptlib.c

index 8384b5d339e062185ea406670d992cf7298ca063..615bcebec476b2e4ee9a214f4a2ccff6c68ddecf 100644 (file)
@@ -693,12 +693,15 @@ void OPENSSL_cpuid_setup(void)
     if (trigger)       return;
 
     trigger=1;
-    if ((env=getenv("OPENSSL_ia32cap")))
+    if ((env=getenv("OPENSSL_ia32cap"))) {
+       int off = (env[0]=='~')?1:0;
 #if defined(_WIN32)
-    {  if (!sscanf(env,"%I64i",&vec)) vec = strtoul(env,NULL,0);   }
+       if (!sscanf(env+off,"%I64i",&vec)) vec = strtoul(env+off,NULL,0);
 #else
-       vec = strtoull(env,NULL,0);
+       vec = strtoull(env+off,NULL,0);
 #endif
+       if (off) vec = OPENSSL_ia32_cpuid()&~vec;
+    }
     else
        vec = OPENSSL_ia32_cpuid();
     /*