aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ahash.c
diff options
context:
space:
mode:
authorTim Chen <tim.c.chen@linux.intel.com>2014-07-10 19:18:08 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-08-25 08:27:16 -0400
commit6d9529c586dbf0d356916d113f72f36397e71cdb (patch)
tree3d3d7e19b45fcadf140ce51694a84b086a87424b /crypto/ahash.c
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
crypto: hash - initialize entry len for null input in crypto hash sg 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>
Diffstat (limited to 'crypto/ahash.c')
-rw-r--r--crypto/ahash.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index f2a5d8f656ff..f6a36a52d738 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -131,8 +131,10 @@ int crypto_hash_walk_first(struct ahash_request *req,
131{ 131{
132 walk->total = req->nbytes; 132 walk->total = req->nbytes;
133 133
134 if (!walk->total) 134 if (!walk->total) {
135 walk->entrylen = 0;
135 return 0; 136 return 0;
137 }
136 138
137 walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req)); 139 walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
138 walk->sg = req->src; 140 walk->sg = req->src;
@@ -147,8 +149,10 @@ int crypto_ahash_walk_first(struct ahash_request *req,
147{ 149{
148 walk->total = req->nbytes; 150 walk->total = req->nbytes;
149 151
150 if (!walk->total) 152 if (!walk->total) {
153 walk->entrylen = 0;
151 return 0; 154 return 0;
155 }
152 156
153 walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req)); 157 walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
154 walk->sg = req->src; 158 walk->sg = req->src;
@@ -167,8 +171,10 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
167{ 171{
168 walk->total = len; 172 walk->total = len;
169 173
170 if (!walk->total) 174 if (!walk->total) {
175 walk->entrylen = 0;
171 return 0; 176 return 0;
177 }
172 178
173 walk->alignmask = crypto_hash_alignmask(hdesc->tfm); 179 walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
174 walk->sg = sg; 180 walk->sg = sg;