diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-04-03 16:19:44 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-04-04 03:44:35 +0200 |
commit | 9917f5821ce8e99d64731f9df891a6879d9f88f1 (patch) | |
tree | 076e0335d229e3d5e4bb932c1802a77de3483ad1 /src/data.c | |
parent | locking: always use _bh (diff) | |
download | wireguard-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.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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; |