Commit 6d9529c586dbf0d356916d113f72f36397e71cdb

Authored by Tim Chen
Committed by Herbert Xu
1 parent 7d1311b93e

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>

Showing 1 changed file with 9 additions and 3 deletions Side-by-side Diff

... ... @@ -131,8 +131,10 @@
131 131 {
132 132 walk->total = req->nbytes;
133 133  
134   - if (!walk->total)
  134 + if (!walk->total) {
  135 + walk->entrylen = 0;
135 136 return 0;
  137 + }
136 138  
137 139 walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
138 140 walk->sg = req->src;
139 141  
... ... @@ -147,8 +149,10 @@
147 149 {
148 150 walk->total = req->nbytes;
149 151  
150   - if (!walk->total)
  152 + if (!walk->total) {
  153 + walk->entrylen = 0;
151 154 return 0;
  155 + }
152 156  
153 157 walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
154 158 walk->sg = req->src;
155 159  
... ... @@ -167,8 +171,10 @@
167 171 {
168 172 walk->total = len;
169 173  
170   - if (!walk->total)
  174 + if (!walk->total) {
  175 + walk->entrylen = 0;
171 176 return 0;
  177 + }
172 178  
173 179 walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
174 180 walk->sg = sg;