From 963e87af644a5563953cf371467f010264077a83 Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Wed, 13 Nov 2019 10:47:26 +0100 Subject: [PATCH] rainbow: memcpy -> memmove since buffers may overlap --- crypto_sign/rainbowIIIc-classic/clean/sign.c | 2 +- crypto_sign/rainbowIIIc-cyclic-compressed/clean/sign.c | 2 +- crypto_sign/rainbowIIIc-cyclic/clean/sign.c | 2 +- crypto_sign/rainbowIa-classic/clean/sign.c | 2 +- crypto_sign/rainbowIa-cyclic-compressed/clean/sign.c | 2 +- crypto_sign/rainbowIa-cyclic/clean/sign.c | 2 +- crypto_sign/rainbowVc-classic/clean/sign.c | 2 +- crypto_sign/rainbowVc-cyclic-compressed/clean/sign.c | 2 +- crypto_sign/rainbowVc-cyclic/clean/sign.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crypto_sign/rainbowIIIc-classic/clean/sign.c b/crypto_sign/rainbowIIIc-classic/clean/sign.c index e724420c..4d7cd1e1 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/sign.c +++ b/crypto_sign/rainbowIIIc-classic/clean/sign.c @@ -44,7 +44,7 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t * rc = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(digest, sm + mlen[0], (const pk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/sign.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/sign.c index 1dcc20d2..8e83a52c 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/sign.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/sign.c @@ -46,7 +46,7 @@ int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_crypto_sign_open(unsigned char *m, rc = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/sign.c b/crypto_sign/rainbowIIIc-cyclic/clean/sign.c index 0f558c48..72a6ca39 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/sign.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/sign.c @@ -46,7 +46,7 @@ int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *m rc = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowIa-classic/clean/sign.c b/crypto_sign/rainbowIa-classic/clean/sign.c index 08405878..ad0647a9 100644 --- a/crypto_sign/rainbowIa-classic/clean/sign.c +++ b/crypto_sign/rainbowIa-classic/clean/sign.c @@ -44,7 +44,7 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *ml rc = PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_verify(digest, sm + mlen[0], (const pk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/sign.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/sign.c index d0687aa3..3dc5694f 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/sign.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/sign.c @@ -46,7 +46,7 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_crypto_sign_open(unsigned char *m, s rc = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowIa-cyclic/clean/sign.c b/crypto_sign/rainbowIa-cyclic/clean/sign.c index cd5c2809..e0a2abc4 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/sign.c +++ b/crypto_sign/rainbowIa-cyclic/clean/sign.c @@ -46,7 +46,7 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mle rc = PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowVc-classic/clean/sign.c b/crypto_sign/rainbowVc-classic/clean/sign.c index 3422f1b9..3c0e56a0 100644 --- a/crypto_sign/rainbowVc-classic/clean/sign.c +++ b/crypto_sign/rainbowVc-classic/clean/sign.c @@ -44,7 +44,7 @@ int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *ml rc = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_verify(digest, sm + mlen[0], (const pk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/sign.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/sign.c index 99f483cb..83241187 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/sign.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/sign.c @@ -46,7 +46,7 @@ int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_crypto_sign_open(unsigned char *m, s rc = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen); diff --git a/crypto_sign/rainbowVc-cyclic/clean/sign.c b/crypto_sign/rainbowVc-cyclic/clean/sign.c index 9b9924d7..41a3d999 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/sign.c +++ b/crypto_sign/rainbowVc-cyclic/clean/sign.c @@ -46,7 +46,7 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_crypto_sign_open(unsigned char *m, size_t *mle rc = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify_cyclic(digest, sm + mlen[0], (const cpk_t *)pk); } if (!rc) { - memcpy(m, sm, smlen - _SIGNATURE_BYTE); + memmove(m, sm, smlen - _SIGNATURE_BYTE); } else { // bad signature *mlen = (size_t) -1; memset(m, 0, smlen);