Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PATCH: fix read -k coredump

0 views
Skip to first unread message

Zoltan Hidvegi

unread,
May 8, 1998, 3:00:00 AM5/8/98
to Zsh hacking and development

This fixes an off-by-one allocation bug.

Zoli


*** Src/builtin.c 1997/07/13 05:24:42 3.1.3.3
--- Src/builtin.c 1997/09/16 04:37:28 3.1.3.4
*************** bin_read(char *name, char **args, char *
*** 2792,2798 ****
char d;

/* allocate buffer space for result */
! bptr = buf = (char *)zalloc(nchars);

do {
/* If read returns 0, is end of file */
--- 2792,2798 ----
char d;

/* allocate buffer space for result */
! bptr = buf = (char *)zalloc(nchars+1);

do {
/* If read returns 0, is end of file */
*************** bin_read(char *name, char **args, char *
*** 2823,2829 ****
if (!ops['e'])
setsparam(reply, metafy(buf, bptr - buf, META_REALLOC));
else
! zfree(buf, bptr - buf);
return val <= 0;
}

--- 2823,2829 ----
if (!ops['e'])
setsparam(reply, metafy(buf, bptr - buf, META_REALLOC));
else
! zfree(buf, bptr - buf + 1);
return val <= 0;
}


0 new messages