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

PATCH: fix read -k coredump



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;
      }
  



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