]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/gawk-3.1.5-segfault_fix-1.patch
strongswan: Update to 5.3.1
[ipfire-2.x.git] / src / patches / gawk-3.1.5-segfault_fix-1.patch
1 Submitted By: Matthew Burgess <matthew@linuxfromscratch.org>
2 Date: 2005-09-24
3 Initial Package Version: 3.1.5
4 Upstream Status: From Upstream
5 Origin: http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00047.html
6 Description: Fixes a bug which causes gawk to segfault when operating on a non-existent file.
7
8 diff -Naur gawk-3.1.5.orig/io.c gawk-3.1.5/io.c
9 --- gawk-3.1.5.orig/io.c 2005-07-26 18:07:43.000000000 +0000
10 +++ gawk-3.1.5/io.c 2005-09-24 14:43:13.771380264 +0000
11 @@ -2480,9 +2480,12 @@
12 {
13 struct stat sbuf;
14 struct open_hook *oh;
15 + int iop_malloced = FALSE;
16
17 - if (iop == NULL)
18 + if (iop == NULL) {
19 emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
20 + iop_malloced = TRUE;
21 + }
22 memset(iop, '\0', sizeof(IOBUF));
23 iop->flag = 0;
24 iop->fd = fd;
25 @@ -2495,7 +2498,8 @@
26 }
27
28 if (iop->fd == INVALID_HANDLE) {
29 - free(iop);
30 + if (iop_malloced)
31 + free(iop);
32 return NULL;
33 }
34 if (isatty(iop->fd))
35 @@ -2503,7 +2507,7 @@
36 iop->readsize = iop->size = optimal_bufsize(iop->fd, & sbuf);
37 iop->sbuf = sbuf;
38 if (do_lint && S_ISREG(sbuf.st_mode) && sbuf.st_size == 0)
39 - lintwarn(_("data file `%s' is empty"), name);
40 + lintwarn(_("data file `%s' is empty"), name);
41 errno = 0;
42 iop->count = iop->scanoff = 0;
43 emalloc(iop->buf, char *, iop->size += 2, "iop_alloc");