diff options
| author | Heiko Schocher <[email protected]> | 2026-01-23 03:25:51 +0100 |
|---|---|---|
| committer | Ilias Apalodimas <[email protected]> | 2026-02-11 11:13:47 +0200 |
| commit | 546687c8dc249447215d091165ed9e820a3f395e (patch) | |
| tree | d4bc5e7baeb7da68f5488b8819cab34370e92063 /lib/sm3.c | |
| parent | 712765339a5c6576fdd5683748f97a1215868d5d (diff) | |
lib: sm3: fix coverity error
Coverity scan reported:
CID 449815: Memory - illegal accesses (OVERRUN)
Overrunning array of 64 bytes at byte offset 64 by dereferencing pointer
"sctx->buffer + partial". [Note: The source code implementation of the
function has been overridden by a builtin model.]
In line: 252
memset(sctx->buffer + partial, 0, SM3_BLOCK_SIZE - partial);
The respective line should be:
memset(sctx->buffer + partial, 0, SM3_BLOCK_SIZE - partial - 1);
as partial gets incremented by one before.
Signed-off-by: Heiko Schocher <[email protected]>
Acked-by: Ilias Apalodimas <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
Diffstat (limited to 'lib/sm3.c')
| -rw-r--r-- | lib/sm3.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sm3.c b/lib/sm3.c index 2a4e825481d..05880099703 100644 --- a/lib/sm3.c +++ b/lib/sm3.c @@ -249,7 +249,7 @@ void sm3_final(struct sm3_context *sctx, uint8_t output[SM3_DIGEST_SIZE]) sctx->buffer[partial++] = 0x80; if (partial > bit_offset) { - memset(sctx->buffer + partial, 0, SM3_BLOCK_SIZE - partial); + memset(sctx->buffer + partial, 0, SM3_BLOCK_SIZE - partial - 1); partial = 0; sm3_block(sctx, sctx->buffer, 1, W); |
