Skip to content

Commit

Permalink
don't memcpy to ourselves (It is undefined)
Browse files Browse the repository at this point in the history
  • Loading branch information
codyps committed Jun 21, 2012
1 parent aa7ee2e commit 4322ebf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crypto-gcrypt.c
Expand Up @@ -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
Expand Down

0 comments on commit 4322ebf

Please sign in to comment.