summaryrefslogtreecommitdiffstats
path: root/src/method_xsalsa20_poly1305.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-01-21 19:07:56 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-01-21 19:07:56 +0100
commit998300562e14f9d07293ec41e1aecca5930d5e6d (patch)
treeb7d6fdaa365aaefa98c39483052bb94064660a28 /src/method_xsalsa20_poly1305.c
parent96c3ad683d87918fd0e6451d37934ba8b1d03867 (diff)
downloadfastd-998300562e14f9d07293ec41e1aecca5930d5e6d.tar
fastd-998300562e14f9d07293ec41e1aecca5930d5e6d.zip
Add error message for OOM on buffer alloc
Diffstat (limited to 'src/method_xsalsa20_poly1305.c')
-rw-r--r--src/method_xsalsa20_poly1305.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/method_xsalsa20_poly1305.c b/src/method_xsalsa20_poly1305.c
index 3e51ad9..655f61b 100644
--- a/src/method_xsalsa20_poly1305.c
+++ b/src/method_xsalsa20_poly1305.c
@@ -140,7 +140,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_buffer_pull_head(&in, crypto_secretbox_xsalsa20poly1305_ZEROBYTES);
memset(in.data, 0, crypto_secretbox_xsalsa20poly1305_ZEROBYTES);
- *out = fastd_buffer_alloc(in.len, 0, 0);
+ *out = fastd_buffer_alloc(ctx, in.len, 0, 0);
uint8_t nonce[crypto_secretbox_xsalsa20poly1305_NONCEBYTES];
memcpy(nonce, session->send_nonce, NONCEBYTES);
@@ -184,7 +184,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_buffer_pull_head(&in, crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES-NONCEBYTES);
memset(in.data, 0, crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES);
- *out = fastd_buffer_alloc(in.len, 0, 0);
+ *out = fastd_buffer_alloc(ctx, in.len, 0, 0);
if (crypto_secretbox_xsalsa20poly1305_open(out->data, in.data, in.len, nonce, session->key) != 0) {
fastd_buffer_free(*out);
@@ -206,7 +206,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
else if (age == 0 || session->receive_reorder_seen & (1 << (age-1))) {
pr_debug(ctx, "dropping duplicate packet from %P (age %u)", peer, (unsigned)age);
fastd_buffer_free(*out);
- *out = fastd_buffer_alloc(crypto_secretbox_xsalsa20poly1305_ZEROBYTES, 0, 0);
+ *out = fastd_buffer_alloc(ctx, crypto_secretbox_xsalsa20poly1305_ZEROBYTES, 0, 0);
}
else {
pr_debug(ctx, "accepting reordered packet from %P (age %u)", peer, (unsigned)age);