From 032c0afdfc6ec3ccf93e50f635a1105d69e0a716 Mon Sep 17 00:00:00 2001 From: forsyth Date: Thu, 30 Jul 2009 19:33:32 +0100 Subject: 20090730-1933 --- libkeyring/dsaalg.c | 13 +++++++++++++ libkeyring/egalg.c | 12 ++++++++++++ libkeyring/rsaalg.c | 12 ++++++++++++ 3 files changed, 37 insertions(+) (limited to 'libkeyring') 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; -- cgit v1.2.3