crypto: fix copy size causing overruns/crashing
PATCH 1/1 crypto: fix copy size causing overruns/crashing
num_ad is already accounted for in sizeof(iov) as iov has size sizeof(struct iovec) * (num_ad+1).
--- src/crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/crypto.c +2 -2
@@ -311,7 +311,7 @@ bool aes_siv_encrypt(const uint8_t *key, size_t key_len, const uint8_t *in,struct iovec iov[num_ad +1 ];uint8_t v[16 ]; -memcpy (iov, ad,sizeof (iov) * num_ad); +memcpy (iov, ad,sizeof (struct iovec ) * num_ad); iov[num_ad].iov_base = (void *)in; iov[num_ad].iov_len = in_len; num_ad++;
@@ -368,7 +368,7 @@ bool aes_siv_decrypt(const uint8_t *key, size_t key_len, const uint8_t *in,if (in_len <16 )return false; -memcpy (iov, ad,sizeof (iov) * num_ad); +memcpy (iov, ad,sizeof (struct iovec ) * num_ad); iov[num_ad].iov_base = (void *)out; iov[num_ad].iov_len = in_len -16 ; num_ad++;
Signature · 1 line
2.23.GIT
Prestwood
Hi Will,
Quoted 11 lines · Will Dietz
num_adis already accounted for insizeof(iov)as iov has sizesizeof(struct iovec) * (num_ad+1).--- src/crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/crypto.c +0
-0
src/crypto.c bool aes_siv_encrypt(const uint8_t *key, size_t · line 315
Quoted 6 lines
src/crypto.c +1
-1@@ -311,7 +311,7 @@ bool aes_siv_encrypt(const uint8_t *key, size_t key_len, const uint8_t *in, struct iovec iov[num_ad + 1];uint8_t v[16 ]; -memcpy (iov, ad,sizeof (iov) * num_ad); +memcpy (iov, ad,sizeof (struct iovec ) * num_ad);
Good catch! I'm fine with this way, but also fine with simply removing
* num_ad and leaving sizeof(iov) as is. Lets see what Denis prefers.
Thanks,
James
Quoted 3 lines
_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org
Prestwood
Quoted 18 lines · James
Hi Will,
Quoted 15 lines · Will Dietz
num_adis already accounted for insizeof(iov)as iov has sizesizeof(struct iovec) * (num_ad+1).--- src/crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/crypto.c +0
-0@@ -311,7 +311,7 @@ bool aes_siv_encrypt(const uint8_t *key, size_t key_len, const uint8_t *in, struct iovec iov[num_ad + 1];uint8_t v[16 ];
Quoted 6 lines
src/crypto.c bool aes_siv_encrypt(const uint8_t *key, size_t · line 315
Quoted 2 lines
src/crypto.c +1
-1-memcpy (iov, ad,sizeof (iov) * num_ad); +memcpy (iov, ad,sizeof (struct iovec ) * num_ad);Good catch! I'm fine with this way, but also fine with simply removing
*num_adand leaving sizeof(iov) as is. Lets see what Denis prefers.
Oh sorry, this wont work. That would copy past 'ad'. Nevermind, lets do it your way ;)
Quoted 10 lines
Thanks,
JamesQuoted 3 lines
_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org_______________________________________________
iwd mailing list -- iwd(a)lists.01.org
To unsubscribe send an email to iwd-leave(a)lists.01.org
Hi James,
Quoted 18 lines · James
Hi Will,
Quoted 15 lines · Will Dietz
num_adis already accounted for insizeof(iov)as iov has sizesizeof(struct iovec) * (num_ad+1).--- src/crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/crypto.c +0
-0@@ -311,7 +311,7 @@ bool aes_siv_encrypt(const uint8_t *key, size_t key_len, const uint8_t *in, struct iovec iov[num_ad + 1];uint8_t v[16 ];
Quoted 6 lines
src/crypto.c bool aes_siv_encrypt(const uint8_t *key, size_t · line 315
Quoted 2 lines
src/crypto.c +1
-1-memcpy (iov, ad,sizeof (iov) * num_ad); +memcpy (iov, ad,sizeof (struct iovec ) * num_ad);Good catch! I'm fine with this way, but also fine with simply removing
*num_adand leaving sizeof(iov) as is. Lets see what Denis prefers.
Not sure that will work since you define iov to be an array of size num_ad + 1?
Regards,
-Denis
Hi Will,
Quoted 6 lines · Will Dietz
num_adis already accounted for insizeof(iov)as iov has sizesizeof(struct iovec) * (num_ad+1).--- src/crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Can you use git send-email to submit this? When I save this message it comes in as multipart with the signature, etc included and seems to confuse git am.
Regards,
-Denis