diff options
Diffstat (limited to 'Src/parse.c')
| -rw-r--r-- | Src/parse.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Src/parse.c b/Src/parse.c index 2b7f8bb59..beb9be059 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -3187,7 +3187,7 @@ bin_zcompile(char *nam, char **args, Options ops, UNUSED(int func)) (OPT_ISSET(ops,'c') && (OPT_ISSET(ops,'U') || OPT_ISSET(ops,'k') || OPT_ISSET(ops,'z'))) || (!(OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) && OPT_ISSET(ops,'m'))) { - zwarnnam(nam, "illegal combination of options"); + zwarnnam(nam, "invalid combination of options"); return 1; } if ((OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) && isset(KSHAUTOLOAD)) @@ -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)) { @@ -3882,10 +3882,16 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh, #ifdef USE_MMAP if (f) { - Eprog prog = (Eprog) zalloc(sizeof(*prog)); + Eprog prog; Patprog *pp; - int np; + size_t np; + if (h->npats > h->len / sizeof(wordcode)) { + zwarn("%s: invalid description: %s", file, name); + return NULL; + } + + prog = (Eprog) zalloc(sizeof(*prog)); prog->flags = EF_MAP; prog->len = h->len; prog->npats = np = h->npats; @@ -3917,7 +3923,15 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh, { Eprog prog; Patprog *pp; - int np, fd, po = h->npats * sizeof(Patprog); + int fd; + size_t np, po; + + if (h->npats > h->len / sizeof(wordcode)) { + zwarn("%s: invalid description: %s", file, name); + return NULL; + } + + po = h->npats * sizeof(Patprog); if ((fd = open(file, O_RDONLY)) < 0 || lseek(fd, ((h->start * sizeof(wordcode)) + |
