summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-12 21:09:18 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-12 21:32:42 -0400
commit4ff170d7b1cbe4074cb85271b82a8963eccc8286 (patch)
tree459640c64a49ee1342338647cd67570cac605516 /src/tools
parent491b6de1684e519d1fec870a5b46a4bb540cbc13 (diff)
downloadtor-4ff170d7b1cbe4074cb85271b82a8963eccc8286.tar.gz
tor-4ff170d7b1cbe4074cb85271b82a8963eccc8286.zip
Fix warnings about passing uninitialized buffers into functions
Most of these buffers were never actually inspected, but it's still bad style.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/tor-gencert.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c
index 395535697f..600e2252d4 100644
--- a/src/tools/tor-gencert.c
+++ b/src/tools/tor-gencert.c
@@ -430,7 +430,7 @@ key_to_string(EVP_PKEY *key)
static int
get_fingerprint(EVP_PKEY *pkey, char *out)
{
- int r = 1;
+ int r = -1;
crypto_pk_t *pk = crypto_new_pk_from_rsa_(EVP_PKEY_get1_RSA(pkey));
if (pk) {
r = crypto_pk_get_fingerprint(pk, out, 0);
@@ -443,7 +443,7 @@ get_fingerprint(EVP_PKEY *pkey, char *out)
static int
get_digest(EVP_PKEY *pkey, char *out)
{
- int r = 1;
+ int r = -1;
crypto_pk_t *pk = crypto_new_pk_from_rsa_(EVP_PKEY_get1_RSA(pkey));
if (pk) {
r = crypto_pk_get_digest(pk, out);
@@ -472,8 +472,12 @@ generate_certificate(void)
char signature[1024]; /* handles up to 8192-bit keys. */
int r;
- get_fingerprint(identity_key, fingerprint);
- get_digest(identity_key, id_digest);
+ if (get_fingerprint(identity_key, fingerprint) < 0) {
+ return -1;
+ }
+ if (get_digest(identity_key, id_digest)) {
+ return -1;
+ }
tor_localtime_r(&now, &tm);
tm.tm_mon += months_lifetime;