diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-12 19:00:55 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-12 19:00:55 +0000 |
commit | 61531f029d65b2db38fa8d6273344753ccdd717f (patch) | |
tree | 2ab4fe686559d3e3cd44bcc0248c3bae0c472342 /contrib/id_to_fp.c | |
parent | 2371369b51f0c32d57f048bd862fd04e83e3ac7f (diff) | |
download | tor-61531f029d65b2db38fa8d6273344753ccdd717f.tar.gz tor-61531f029d65b2db38fa8d6273344753ccdd717f.zip |
r8791@Kushana: nickm | 2006-09-12 15:00:48 -0400
As long as we are being pedantic, we may as well be extra-pedantic.
svn:r8376
Diffstat (limited to 'contrib/id_to_fp.c')
-rw-r--r-- | contrib/id_to_fp.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/contrib/id_to_fp.c b/contrib/id_to_fp.c index 428f37d1b9..e6f9f46279 100644 --- a/contrib/id_to_fp.c +++ b/contrib/id_to_fp.c @@ -14,16 +14,17 @@ #include <stdio.h> #include <stdlib.h> -#define die(s) do { fprintf(stderr, "%s\n", s); return 1; } while (0) +#define die(s) do { fprintf(stderr, "%s\n", s); goto err; } while (0) int main(int argc, char **argv) { - BIO *b; - RSA *key; - unsigned char *buf, *bufp; + BIO *b = NULL; + RSA *key = NULL; + unsigned char *buf = NULL, *bufp; int len, i; unsigned char digest[20]; + int status = 1; if (argc != 2) die("I want a filename"); @@ -34,7 +35,11 @@ main(int argc, char **argv) die("couldn't parse key"); len = i2d_RSAPublicKey(key, NULL); + if (len < 0) + die("Bizarre key"); bufp = buf = malloc(len+1); + if (!buf) + die("Out of memory"); len = i2d_RSAPublicKey(key, &bufp); if (len < 0) die("Bizarre key"); @@ -45,6 +50,15 @@ main(int argc, char **argv) } printf("\n"); - return 0; + status = 0; + +err: + if (buf) + free(buf); + if (key) + RSA_free(key); + if (b) + BIO_free(b); + return status; } |