]> git.corax.cc Git - corax/commitdiff
sys_debug: Make sure strings are properly NUL-terminated before passing them to dbg_p...
authorMatthias Kruk <m@m10k.eu>
Sun, 5 Jan 2020 08:01:19 +0000 (17:01 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 5 Jan 2020 08:01:19 +0000 (17:01 +0900)
kernel/core/posixcall.c

index 289a9eec16bf93537c07acaf70aec72d9ec521ca..7fe4b57b446d3a3e02fab38ae7fa209f3d8605b1 100644 (file)
@@ -413,10 +413,10 @@ int sys_debug(const char *str, const u32_t len)
        process_t *cproc;
 
        cproc = process_get_current();
-       ret_val = len < sizeof(buffer) ? len : sizeof(buffer);
+       ret_val = len < (sizeof(buffer) - 1) ? len : (sizeof(buffer) - 1);
 
        process_memcpy_ptok(cproc, buffer, str, ret_val);
-       buffer[sizeof(buffer) - 1] = 0;
+       buffer[ret_val] = 0;
 
        dbg_printf("%s\n", buffer);