From 57bacd2c38456a8d517484c652280f6eda14b2e3 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Thu, 23 Mar 2023 12:02:57 +0100 Subject: [PATCH] Fixed NULL += 0 undefined behaviour --- src/monocypher.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/monocypher.c b/src/monocypher.c index 0257fb5..7fdebb0 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -377,6 +377,11 @@ void crypto_poly1305_init(crypto_poly1305_ctx *ctx, const u8 key[32]) void crypto_poly1305_update(crypto_poly1305_ctx *ctx, const u8 *message, size_t message_size) { + // Avoid undefined NULL pointer increments with empty messages + if (message_size == 0) { + return; + } + // Align ourselves with block boundaries size_t aligned = MIN(gap(ctx->c_idx, 16), message_size); FOR (i, 0, aligned) { -- 2.47.3