diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-14 21:43:56 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2009-07-14 21:43:56 +0800 |
commit | 0e2d3a126338ebb213c8e32d8d1d8936d8e62d43 (patch) | |
tree | 1ff96752beb00d53321f2929c805552b4cb29742 /crypto/shash.c | |
parent | 8c32c516eb1c1f9c14d25478442137c698788975 (diff) | |
download | linux-3.10-0e2d3a126338ebb213c8e32d8d1d8936d8e62d43.tar.gz linux-3.10-0e2d3a126338ebb213c8e32d8d1d8936d8e62d43.tar.bz2 linux-3.10-0e2d3a126338ebb213c8e32d8d1d8936d8e62d43.zip |
crypto: shash - Fix alignment in unaligned operations
When we encounter an unaligned pointer we are supposed to copy
it to a temporary aligned location. However the temporary buffer
isn't aligned properly. This patch fixes that.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/shash.c')
-rw-r--r-- | crypto/shash.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index e54328364a8..171c8f052f8 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -76,8 +76,9 @@ static int shash_update_unaligned(struct shash_desc *desc, const u8 *data, unsigned long alignmask = crypto_shash_alignmask(tfm); unsigned int unaligned_len = alignmask + 1 - ((unsigned long)data & alignmask); - u8 buf[shash_align_buffer_size(unaligned_len, alignmask)] + u8 ubuf[shash_align_buffer_size(unaligned_len, alignmask)] __attribute__ ((aligned)); + u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1); int err; if (unaligned_len > len) @@ -111,8 +112,9 @@ static int shash_final_unaligned(struct shash_desc *desc, u8 *out) unsigned long alignmask = crypto_shash_alignmask(tfm); struct shash_alg *shash = crypto_shash_alg(tfm); unsigned int ds = crypto_shash_digestsize(tfm); - u8 buf[shash_align_buffer_size(ds, alignmask)] + u8 ubuf[shash_align_buffer_size(ds, alignmask)] __attribute__ ((aligned)); + u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1); int err; err = shash->final(desc, buf); |