diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-11-14 11:51:25 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-11-14 11:51:25 +0000 |
commit | 2d77bd0d58490cb5df833b9ccc3d479267f879f6 (patch) | |
tree | e9a90874f6516f4130d36a2dc3499296854226f6 | |
parent | 7dadc4e18e8286f5d90968c8b5e44910f3fa837d (diff) | |
download | zsh-2d77bd0d58490cb5df833b9ccc3d479267f879f6.tar.gz zsh-2d77bd0d58490cb5df833b9ccc3d479267f879f6.tar.xz zsh-2d77bd0d58490cb5df833b9ccc3d479267f879f6.zip |
don't be sure that read-ahead doesn't contains nuls (13163)
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/Modules/zpty.c | 13 |
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog index 892627e25..70b9906ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-11-14 Sven Wischnowsky <wischnow@zsh.org> + + * 13163: Src/Modules/zpty.c: don't be sure that read-ahead doesn't + contains nuls + 2000-11-13 Peter Stephenson <pws@csr.com> * unposted: config.sub, config.status: updated from GNU sources, diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index dcca286c0..297833a79 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -49,6 +49,7 @@ struct ptycmd { int fin; int read; char *old; + int olen; }; static Ptycmd ptycmds; @@ -375,6 +376,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) p->fin = 0; p->read = -1; p->old = NULL; + p->olen = 0; p->next = ptycmds; ptycmds = p; @@ -462,11 +464,12 @@ ptyread(char *nam, Ptycmd cmd, char **args) fflush(stdout); if (cmd->old) { - used = strlen(cmd->old); + used = cmd->olen; buf = (char *) zhalloc((blen = 256 + used) + 1); - strcpy(buf, cmd->old); - zsfree(cmd->old); + memcpy(buf, cmd->old, cmd->olen); + zfree(cmd->old, cmd->olen); cmd->old = NULL; + cmd->olen = 0; } else { used = 0; buf = (char *) zhalloc((blen = 256) + 1); @@ -516,8 +519,8 @@ ptyread(char *nam, Ptycmd cmd, char **args) #endif #endif ) { - cmd->old = ztrdup(buf); - used = 0; + cmd->old = (char *) zalloc(cmd->olen = used); + memcpy(cmd->old, buf, cmd->olen); return 1; } |