]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
hash: initialize return value before calling NSS hash functions
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 19 Mar 2018 12:02:47 +0000 (13:02 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 28 Mar 2018 14:57:48 +0000 (16:57 +0200)
Some hash functions in the freebl3 library don't support truncated
digests and either return immediately with no update of the output
length, or ignore the length of the output buffer and always write whole
digest.

Initialize the return value to zero to get correct result with the
former.

This is triggered only in the hash unit test. chronyd always provides a
sufficient buffer for the digest.

hash_nss.c

index 71c89303f1260323434ba40a8f1cd36594ec168e..eb1f050dd9d92a9f976a7cba48dc7b8c03c56476 100644 (file)
@@ -78,7 +78,7 @@ HSH_Hash(int id, const unsigned char *in1, unsigned int in1_len,
     const unsigned char *in2, unsigned int in2_len,
     unsigned char *out, unsigned int out_len)
 {
-  unsigned int ret;
+  unsigned int ret = 0;
 
   NSSLOWHASH_Begin(hashes[id].context);
   NSSLOWHASH_Update(hashes[id].context, in1, in1_len);