Avoid a null pointer dereference, so 'xargs <<< ${EMTPY_VARIABLE}'

will not segfault and dump core.

Submitted by:	Robert Nagy <robert@openbsd.org>
This commit is contained in:
David E. O'Brien 2004-06-20 22:37:22 +00:00
parent eeea5a46e1
commit edd5ce97c3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=111891
6 changed files with 63 additions and 3 deletions

View file

@ -8,7 +8,7 @@
PORTNAME= bash
PORTVERSION= 2.05b.007
PORTREVISION?= 0
PORTREVISION?= 1
CATEGORIES= shells
MASTER_SITES= ${MASTER_SITE_GNU} \
ftp://ftp.cwru.edu/pub/bash/

View file

@ -0,0 +1,20 @@
Index: files/patch-redir.c
===================================================================
RCS file: files/patch-redir.c
diff -N files/patch-redir.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/patch-redir.c 20 Jun 2004 15:40:43 -0000
@@ -0,0 +1,11 @@
+--- redir.c.orig Sun Jun 20 18:00:47 2004
++++ redir.c Sun Jun 20 18:01:25 2004
+@@ -263,7 +263,7 @@
+ int herelen, n, e;
+
+ herestr = expand_string_to_string (redirectee->word, 0);
+- herelen = strlen (herestr);
++ herelen = (herestr == NULL) ? 0 : strlen (herestr);
+
+ n = write (fd, herestr, herelen);
+ if (n == herelen)

View file

@ -8,7 +8,7 @@
PORTNAME= bash
PORTVERSION= 2.05b.007
PORTREVISION?= 0
PORTREVISION?= 1
CATEGORIES= shells
MASTER_SITES= ${MASTER_SITE_GNU} \
ftp://ftp.cwru.edu/pub/bash/

View file

@ -0,0 +1,20 @@
Index: files/patch-redir.c
===================================================================
RCS file: files/patch-redir.c
diff -N files/patch-redir.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/patch-redir.c 20 Jun 2004 15:40:43 -0000
@@ -0,0 +1,11 @@
+--- redir.c.orig Sun Jun 20 18:00:47 2004
++++ redir.c Sun Jun 20 18:01:25 2004
+@@ -263,7 +263,7 @@
+ int herelen, n, e;
+
+ herestr = expand_string_to_string (redirectee->word, 0);
+- herelen = strlen (herestr);
++ herelen = (herestr == NULL) ? 0 : strlen (herestr);
+
+ n = write (fd, herestr, herelen);
+ if (n == herelen)

View file

@ -8,7 +8,7 @@
PORTNAME= bash
PORTVERSION= 2.05b.007
PORTREVISION?= 0
PORTREVISION?= 1
CATEGORIES= shells
MASTER_SITES= ${MASTER_SITE_GNU} \
ftp://ftp.cwru.edu/pub/bash/

View file

@ -0,0 +1,20 @@
Index: files/patch-redir.c
===================================================================
RCS file: files/patch-redir.c
diff -N files/patch-redir.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ files/patch-redir.c 20 Jun 2004 15:40:43 -0000
@@ -0,0 +1,11 @@
+--- redir.c.orig Sun Jun 20 18:00:47 2004
++++ redir.c Sun Jun 20 18:01:25 2004
+@@ -263,7 +263,7 @@
+ int herelen, n, e;
+
+ herestr = expand_string_to_string (redirectee->word, 0);
+- herelen = strlen (herestr);
++ herelen = (herestr == NULL) ? 0 : strlen (herestr);
+
+ n = write (fd, herestr, herelen);
+ if (n == herelen)