From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Wed, 3 Jul 2024 22:41:08 +0200
Subject: [PATCH] spio: Don't write to non-allocate memory.

spio::line has a size of SP_LINE_LENGTH items starting at 0 ending at
SP_LINE_LENGTH - 1. Accessing item SP_LINE_LENGTH is out of bounds, it
no longer part of spio::line.

Use `SP_LINE_LENGTH - 1' as the last character.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
 common/spio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spio.c b/common/spio.c
index e25ef3dde5da..6629e72c33fd 100644
--- a/common/spio.c
+++ b/common/spio.c
@@ -463,7 +463,7 @@ int read_raw(spctx_t* ctx, spio_t* io, int opts)
             io->_ln = 0;
             
             /* Null terminate */
-            io->line[SP_LINE_LENGTH] = 0;
+            io->line[SP_LINE_LENGTH -1] = 0;
             
             /* A double check on the return value */
             return count;
-- 
2.45.2

