Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Coverity CID 1692314 avoid overflowing version field in dump header



This would only happen if you at compile time make the version string 40
characters or longer, which would be quite silly.
---
 Src/parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Src/parse.c b/Src/parse.c
index 2b7f8bb595..21b95bcb7d 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3350,7 +3350,7 @@ write_dump(int dfd, LinkList progs, int map, int hlen, int tlen)
 	fdmagic(pre) = (other ? FD_OMAGIC : FD_MAGIC);
 	fdsetflags(pre, ((map ? FDF_MAP : 0) | other));
 	fdsetother(pre, tlen);
-	strcpy(fdversion(pre), ZSH_VERSION);
+	strncpy(fdversion(pre), ZSH_VERSION, sizeof(wordcode) * (FD_PRELEN - 2) - 1);
 	write_loop(dfd, (char *)pre, FD_PRELEN * sizeof(wordcode));
 
 	for (node = firstnode(progs); node; incnode(node)) {
-- 
2.38.1





Messages sorted by: Reverse Date, Date, Thread, Author