Skip to content

Commit

Permalink
crypto: hash - initialize entry len for null input in crypto hash sg …
Browse files Browse the repository at this point in the history
…list walk

For the special case when we have a null input string, we want
to initialize the entry len to 0 for the hash/ahash walk, so
cyrpto_hash_walk_last will return the correct result indicating
that we have completed the scatter list walk.  Otherwise we may
keep walking the sg list and access bogus memory address.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Tim Chen authored and Herbert Xu committed Aug 25, 2014
1 parent 7d1311b commit 6d9529c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ int crypto_hash_walk_first(struct ahash_request *req,
{
walk->total = req->nbytes;

if (!walk->total)
if (!walk->total) {
walk->entrylen = 0;
return 0;
}

walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
walk->sg = req->src;
Expand All @@ -147,8 +149,10 @@ int crypto_ahash_walk_first(struct ahash_request *req,
{
walk->total = req->nbytes;

if (!walk->total)
if (!walk->total) {
walk->entrylen = 0;
return 0;
}

walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
walk->sg = req->src;
Expand All @@ -167,8 +171,10 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
{
walk->total = len;

if (!walk->total)
if (!walk->total) {
walk->entrylen = 0;
return 0;
}

walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
walk->sg = sg;
Expand Down

0 comments on commit 6d9529c

Please sign in to comment.