]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Fix uses of strlcpy on unterminated source strings
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index 8c6570ecdf3447017e2549ae23c880610e98975d..667b9009b0d24f858574311f0e84a03a94ca1615 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -169,7 +169,8 @@ static cmd_input_t *Cbuf_NodeGet(cmd_buf_t *cbuf, cmd_input_t *existing)
 ============
 Cbuf_LinkString
 
-Copies a command string into a buffer node
+Copies a command string into a buffer node.
+The input should not be null-terminated, the output will be.
 ============
 */
 static void Cbuf_LinkString(cmd_state_t *cmd, llist_t *head, cmd_input_t *existing, const char *text, qbool leavepending, unsigned int cmdsize)
@@ -193,7 +194,7 @@ static void Cbuf_LinkString(cmd_state_t *cmd, llist_t *head, cmd_input_t *existi
        }
        cbuf->size += cmdsize;
 
-       dp_strlcpy(&node->text[offset], text, cmdsize + 1); // always sets the last char to \0
+       dp_ustr2stp(&node->text[offset], node->length + 1, text, cmdsize);
        //Con_Printf("^5Cbuf_LinkString(): %s `^7%s^5`\n", node->pending ? "append" : "new", &node->text[offset]);
        node->pending = leavepending;
 }