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

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.