From e3662a7ccb070685dd6f2a1516010a1494c44201 Mon Sep 17 00:00:00 2001 From: Nickolay Olshevsky <o.nickolay@gmail.com> Date: Sun, 28 Jul 2024 11:34:09 +0300 Subject: [PATCH] Fix CID 1547465: Integer handling issues --- src/librepgp/stream-armor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librepgp/stream-armor.cpp b/src/librepgp/stream-armor.cpp index bb9355b8..dc1e12e8 100644 --- a/src/librepgp/stream-armor.cpp +++ b/src/librepgp/stream-armor.cpp @@ -1154,10 +1154,10 @@ pgp_source_t::is_cleartext() char buf[ARMORED_PEEK_BUF_SIZE] = {0}; size_t read = 0; - if (!peek(buf, sizeof(buf), &read) || (read < strlen(ST_CLEAR_BEGIN))) { + if (!peek(buf, sizeof(buf) - 1, &read) || (read < strlen(ST_CLEAR_BEGIN))) { return false; } - buf[read - 1] = 0; + buf[read] = 0; return !!strstr(buf, ST_CLEAR_BEGIN); }