From: Loup Vaillant Date: Thu, 23 Mar 2023 11:02:57 +0000 (+0100) Subject: Fixed NULL += 0 undefined behaviour X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=57bacd2c38456a8d517484c652280f6eda14b2e3;p=Monocypher.git Fixed NULL += 0 undefined behaviour --- 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) {