aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/data.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-04-03 16:19:44 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-04-04 03:44:35 +0200
commit9917f5821ce8e99d64731f9df891a6879d9f88f1 (patch)
tree076e0335d229e3d5e4bb932c1802a77de3483ad1 /src/data.c
parentlocking: always use _bh (diff)
downloadwireguard-monolithic-historical-9917f5821ce8e99d64731f9df891a6879d9f88f1.tar.xz
wireguard-monolithic-historical-9917f5821ce8e99d64731f9df891a6879d9f88f1.zip
chacha20poly1305: check return values of sgops
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/data.c b/src/data.c
index 4751eb8..ddb99b0 100644
--- a/src/data.c
+++ b/src/data.c
@@ -164,10 +164,9 @@ static inline bool skb_encrypt(struct sk_buff *skb, struct noise_keypair *keypai
/* Now we can encrypt the scattergather segments */
sg = __builtin_alloca(num_frags * sizeof(struct scatterlist)); /* bounded to 128 */
sg_init_table(sg, num_frags);
- skb_to_sgvec(skb, sg, sizeof(struct message_data), noise_encrypted_len(plaintext_len));
- chacha20poly1305_encrypt_sg(sg, sg, plaintext_len, NULL, 0, PACKET_CB(skb)->nonce, keypair->sending.key, have_simd);
-
- return true;
+ if (skb_to_sgvec(skb, sg, sizeof(struct message_data), noise_encrypted_len(plaintext_len)) <= 0)
+ return false;
+ return chacha20poly1305_encrypt_sg(sg, sg, plaintext_len, NULL, 0, PACKET_CB(skb)->nonce, keypair->sending.key, have_simd);
}
static inline bool skb_decrypt(struct sk_buff *skb, struct noise_symmetric_key *key)
@@ -192,7 +191,8 @@ static inline bool skb_decrypt(struct sk_buff *skb, struct noise_symmetric_key *
sg = __builtin_alloca(num_frags * sizeof(struct scatterlist)); /* bounded to 128 */
sg_init_table(sg, num_frags);
- skb_to_sgvec(skb, sg, 0, skb->len);
+ if (skb_to_sgvec(skb, sg, 0, skb->len) <= 0)
+ return false;
if (!chacha20poly1305_decrypt_sg(sg, sg, skb->len, NULL, 0, PACKET_CB(skb)->nonce, key->key))
return false;