diff options
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | include/version.h | 2 | ||||
| -rw-r--r-- | libinterp/keyring.c | 2 | ||||
| -rw-r--r-- | libkeyring/dsaalg.c | 13 | ||||
| -rw-r--r-- | libkeyring/egalg.c | 12 | ||||
| -rw-r--r-- | libkeyring/rsaalg.c | 12 |
6 files changed, 42 insertions, 1 deletions
@@ -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; |
