Linux cryptographic layer development
 help / color / mirror / Atom feed
* Dead code in crypto/tcrypt.c
@ 2006-09-26 11:05 Eric Sesterhenn
  2006-09-27 11:09 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sesterhenn @ 2006-09-26 11:05 UTC (permalink / raw)
  To: linux-crypto

hi,

the following commit added some code in test_hash_cycles() which coverity flags as dead code.
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e9d41164e2fdd897fe4520c2079ea0000f6e0ec3

The culprit are the following lines:


	for (i = 0; i < 4; i++) {
- 		crypto_digest_init(tfm);
+ 		ret = crypto_hash_init(desc);
+ 		if (ret)
+ 			goto out;
		for (pcount = 0; pcount < blen; pcount += plen) {
			sg_set_buf(sg, p + pcount, plen);
- 			crypto_digest_update(tfm, sg, 1);
+ 			ret = crypto_hash_update(desc, sg, plen);
+ 			if (ret)
+ 				goto out;
		}
- 		crypto_digest_final(tfm, out);
+ 		crypto_hash_final(desc, out);
+ 		if (ret)
+ 			goto out;
	}

We check ret before the for loop, and inside it, and
there is no way it can change in between. Are we missing
to assign the return value of crypto_hash_final() to ret?

Greetings, Eric


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Dead code in crypto/tcrypt.c
  2006-09-26 11:05 Dead code in crypto/tcrypt.c Eric Sesterhenn
@ 2006-09-27 11:09 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2006-09-27 11:09 UTC (permalink / raw)
  To: Eric Sesterhenn; +Cc: linux-crypto

Eric Sesterhenn <snakebyte@gmx.de> wrote:
> 
> the following commit added some code in test_hash_cycles() which coverity flags as dead code.
> http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e9d41164e2fdd897fe4520c2079ea0000f6e0ec3

Thanks for spotting this.  I've put the following patch
into the tree.
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 8330742..587a135 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -646,7 +646,7 @@ static int test_hash_cycles(struct hash_
 			if (ret)
 				goto out;
 		}
-		crypto_hash_final(desc, out);
+		ret = crypto_hash_final(desc, out);
 		if (ret)
 			goto out;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-09-27 11:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 11:05 Dead code in crypto/tcrypt.c Eric Sesterhenn
2006-09-27 11:09 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox