summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2009-07-30 19:33:32 +0100
committerforsyth <forsyth@vitanuova.com>2009-07-30 19:33:32 +0100
commit032c0afdfc6ec3ccf93e50f635a1105d69e0a716 (patch)
treea0ebc214dbb4b214d56709185ea4921309263c62
parentea1a81b6f8df49918483d91781f2791edf95a523 (diff)
20090730-1933
-rw-r--r--CHANGES2
-rw-r--r--include/version.h2
-rw-r--r--libinterp/keyring.c2
-rw-r--r--libkeyring/dsaalg.c13
-rw-r--r--libkeyring/egalg.c12
-rw-r--r--libkeyring/rsaalg.c12
6 files changed, 42 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index ba465c08..8c19d2a4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+20090730
+ improve the error checking in strtosk and strtopk to help detect mangled or inappropriate keys
20090728
emu/port/main.c: put host's working directory name as emuwdir
document initial environment variables in emu(1)
diff --git a/include/version.h b/include/version.h
index e72f45a6..23d57f5d 100644
--- a/include/version.h
+++ b/include/version.h
@@ -1 +1 @@
-#define VERSION "Fourth Edition (20090728)"
+#define VERSION "Fourth Edition (20090730)"
diff --git a/libinterp/keyring.c b/libinterp/keyring.c
index 3fa41249..6b44c16d 100644
--- a/libinterp/keyring.c
+++ b/libinterp/keyring.c
@@ -177,6 +177,8 @@ base64tobig(char *str, char **strp)
for(p = str; *p && *p != '\n'; p++)
;
+ if(p == str)
+ return nil;
n = dec64(hex, sizeof(hex), str, p - str);
b = betomp(hex, n, nil);
if(strp){
diff --git a/libkeyring/dsaalg.c b/libkeyring/dsaalg.c
index 2af1edc9..9845d5f0 100644
--- a/libkeyring/dsaalg.c
+++ b/libkeyring/dsaalg.c
@@ -25,6 +25,11 @@ dsa_str2sk(char *str, char **strp)
dsa->secret = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(dsa->pub.p == nil || dsa->pub.q == nil ||
+ dsa->pub.alpha == nil || dsa->pub.key == nil || dsa->secret == nil){
+ dsaprivfree(dsa);
+ return nil;
+ }
return dsa;
}
@@ -41,6 +46,10 @@ dsa_str2pk(char *str, char **strp)
dsa->key = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(dsa->p == nil || dsa->q == nil || dsa->alpha == nil || dsa->key == nil){
+ dsapubfree(dsa);
+ return nil;
+ }
return dsa;
}
@@ -55,6 +64,10 @@ dsa_str2sig(char *str, char **strp)
dsa->s = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(dsa->r == nil || dsa->s == nil){
+ dsasigfree(dsa);
+ return nil;
+ }
return dsa;
}
diff --git a/libkeyring/egalg.c b/libkeyring/egalg.c
index 3a914d0f..0c6b88d1 100644
--- a/libkeyring/egalg.c
+++ b/libkeyring/egalg.c
@@ -24,6 +24,10 @@ eg_str2sk(char *str, char **strp)
eg->secret = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(eg->pub.p == nil || eg->pub.alpha == nil || eg->pub.key == nil || eg->secret == nil){
+ egprivfree(eg);
+ return nil;
+ }
return eg;
}
@@ -39,6 +43,10 @@ eg_str2pk(char *str, char **strp)
eg->key = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(eg->p == nil || eg->alpha == nil || eg->key == nil){
+ egpubfree(eg);
+ return nil;
+ }
return eg;
}
@@ -53,6 +61,10 @@ eg_str2sig(char *str, char **strp)
eg->s = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(eg->r == nil || eg->s == nil){
+ egsigfree(eg);
+ return nil;
+ }
return eg;
}
diff --git a/libkeyring/rsaalg.c b/libkeyring/rsaalg.c
index 44c3c262..f522f485 100644
--- a/libkeyring/rsaalg.c
+++ b/libkeyring/rsaalg.c
@@ -28,6 +28,12 @@ rsa_str2sk(char *str, char **strp)
rsa->c2 = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(rsa->pub.n == nil || rsa->pub.ek == nil ||
+ rsa->dk == nil || rsa->p == nil || rsa->q == nil ||
+ rsa->kp == nil || rsa->kq == nil || rsa->c2 == nil){
+ rsaprivfree(rsa);
+ return nil;
+ }
return rsa;
}
@@ -43,6 +49,10 @@ rsa_str2pk(char *str, char **strp)
rsa->ek = base64tobig(p, &p);
if(strp)
*strp = p;
+ if(rsa->n == nil || rsa->ek == nil){
+ rsapubfree(rsa);
+ return nil;
+ }
return rsa;
}
@@ -54,6 +64,8 @@ rsa_str2sig(char *str, char **strp)
char *p;
rsa = base64tobig(str, &p);
+ if(rsa == nil)
+ return nil;
if(strp)
*strp = p;
return rsa;