fix use of strncpy (thanks Hiltjo Posthuma) - xml2tsv - a simple xml-to-tsv converter, based on xmlparser
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 8cf4ed89a038cae37878fead482aec23a9755e9e
(DIR) parent d10d115bb1de07e38a31f2e5946150f1f86e2d3e
(HTM) Author: KatolaZ <katolaz@freaknet.org>
Date: Fri, 3 Jan 2020 12:47:08 +0000
fix use of strncpy (thanks Hiltjo Posthuma)
Diffstat:
M xml2tsv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/xml2tsv.c b/xml2tsv.c
@@ -1,7 +1,7 @@
/*
* (c) 2020 Vincenzo "KatolaZ" Nicosia <katolaz@freaknet.org>
*
-* A simple xml-to-rsv converter, based on xmlparser by Hiltjo Posthuma
+* A simple xml-to-tsv converter, based on xmlparser by Hiltjo Posthuma
* http://codemadness.org/git/xmlparser/
*
* You can use, distribute, modify, and/or redistribute this program under
@@ -31,7 +31,8 @@ typedef struct {
int stack_push(tstack_t *t, const char *c){
if (t->top < DEPTH_MAX){
t->top ++;
- strncpy(t->st[t->top], c, STR_MAX);
+ strncpy(t->st[t->top], c, STR_MAX - 1);
+ *(t->st[t->top] + STR_MAX) = '\0';
return 0;
}
return -1;