Date: Fri, 15 Sep 2006 10:20:28 GMT From: Ruslan Ermilov <ru@FreeBSD.org> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6 Message-ID: <200609151020.k8FAKSS2044491@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/100443; it has been noted by GNATS. From: Ruslan Ermilov <ru@FreeBSD.org> To: "Devon H. O'Dell" <devon.odell@coyotepoint.com>, Dmitry Marakasov <amdmi3@mail.ru> Cc: bug-followup@FreeBSD.org Subject: Re: bin/100443 : awk(1) dies with SIGBUS when processing INDEX-6 Date: Fri, 15 Sep 2006 14:14:17 +0400 On Thu, Sep 14, 2006 at 07:15:00PM -0400, Devon H. O'Dell wrote: > Ruslan Ermilov wrote: > >On Thu, Sep 14, 2006 at 09:40:24PM +0000, Devon H. O'Dell wrote: > [snip] > >> Do we need to send this upstream? > >> > >Yes, of course. > > I sent an email to BWK a couple hours ago -- hopefully he'll get it soon :) > There's another function, refldbld(), that needs a similar fix. Actually, your patch makes it so that if "n == fieldssize" then malloc() will be redundantly called, when we enter this function again and again. I think the following should fix it better: %%% Index: lib.c =================================================================== RCS file: /home/ncvs/src/contrib/one-true-awk/lib.c,v retrieving revision 1.1.1.4 diff -u -p -r1.1.1.4 lib.c --- lib.c 16 May 2005 19:11:33 -0000 1.1.1.4 +++ lib.c 15 Sep 2006 10:10:59 -0000 @@ -58,7 +58,7 @@ static Cell dollar1 = { OCELL, CFLD, NUL void recinit(unsigned int n) { if ( (record = (char *) malloc(n)) == NULL - || (fields = (char *) malloc(n)) == NULL + || (fields = (char *) malloc(n+1)) == NULL || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL ) FATAL("out of space for $0 and fields"); %%% Could you please send me the code/scripts to reproduce a segfault? Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609151020.k8FAKSS2044491>