You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/26 15:04:51 UTC

(mynewt-core) 05/08: sys/config: Fix buffer size check in conf_get_stored_value

This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 7586b9ab255d054864d96e76e964925ac43cb9ba
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Sun Oct 25 23:31:13 2026 +0100

    sys/config: Fix buffer size check in conf_get_stored_value
    
    Buffer size was compared against string length without terminating
    NUL, so a value of exactly buffer size was accepted and NUL was
    written past the buffer.
    
    Assisted-by: Claude:claude-opus-5-5
---
 sys/config/src/config_store.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/config/src/config_store.c b/sys/config/src/config_store.c
index f1ac586a0..276ee2e2b 100644
--- a/sys/config/src/config_store.c
+++ b/sys/config/src/config_store.c
@@ -179,7 +179,7 @@ conf_get_stored_value(char *name, char *buf, int buf_len)
         return OS_ENOENT;
     }
     val_len = strlen(cgva.val);
-    if (buf_len < val_len) {
+    if (buf_len <= val_len) {
         return OS_EINVAL;
     }
     strcpy(buf, cgva.val);