Permalink
Browse files

don't memcpy to ourselves (It is undefined)

  • Loading branch information...
1 parent aa7ee2e commit 4322ebf8984ec205e08ccaf106a7fe5bba6e38dd @jmesmon jmesmon committed Jun 15, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 crypto-gcrypt.c
View
@@ -171,7 +171,10 @@ syscrypt(struct tc_crypto_algo *cipher, unsigned char *key, size_t klen, unsigne
return EINVAL;
}
- memcpy(out, in, len);
+ /* When chaining ciphers, we reuse the input buffer as the output buffer */
+ if (out != in)
+ memcpy(out, in, len);
+
if (do_encrypt)
err = xts_encrypt(ctx, out, len, iv);
else

0 comments on commit 4322ebf

Please sign in to comment.