All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix some bash errors
@ 2014-04-01  1:59 Kai Kang
  2014-04-01  1:59 ` [PATCH] bash-3.2.48: fix error path of getc_with_restart Kai Kang
  2014-04-01 10:14 ` [PATCH] Fix some bash errors Kang Kai
  0 siblings, 2 replies; 3+ messages in thread
From: Kai Kang @ 2014-04-01  1:59 UTC (permalink / raw)
  To: openembedded-core

Fix some errors for bash 3.2.48 by take patches from bash 4.3.

Yong Zhang (1):
  bash-3.2.48: fix error path of getc_with_restart

 .../bash-fix-error-path-of-getc_with_restart.patch | 41 ++++++++++++++++++++++
 .../bash-3.2.48/bash-fix-getc_with_restart.patch   | 28 +++++++++++++++
 meta/recipes-extended/bash/bash_3.2.48.bb          |  2 ++
 3 files changed, 71 insertions(+)
 create mode 100644 meta/recipes-extended/bash/bash-3.2.48/bash-fix-error-path-of-getc_with_restart.patch
 create mode 100644 meta/recipes-extended/bash/bash-3.2.48/bash-fix-getc_with_restart.patch

-- 
1.8.1.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] bash-3.2.48: fix error path of getc_with_restart
  2014-04-01  1:59 [PATCH] Fix some bash errors Kai Kang
@ 2014-04-01  1:59 ` Kai Kang
  2014-04-01 10:14 ` [PATCH] Fix some bash errors Kang Kai
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Kang @ 2014-04-01  1:59 UTC (permalink / raw)
  To: openembedded-core

From: Yong Zhang <yong.zhang@windriver.com>

1. let getc_with_restart() handle EAGAIN|EWOULDBLOCK
   correctly.
2. When read() returns with ERROR, local_bufused will be set
   to -1; and if we return with local_bufused == -1 left,
   the next time we call getc_with_restart(), the condition
   (local_index == local_bufused || local_bufused == 0)
   will not match, thus we get random data from localbuf[]
   with local_index increased each time, eventually we may
   access data beyond array localbuf[]. Fix it by resetting
   local_index and local_bufused in case of read failure.

Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 .../bash-fix-error-path-of-getc_with_restart.patch | 41 ++++++++++++++++++++++
 .../bash-3.2.48/bash-fix-getc_with_restart.patch   | 28 +++++++++++++++
 meta/recipes-extended/bash/bash_3.2.48.bb          |  2 ++
 3 files changed, 71 insertions(+)
 create mode 100644 meta/recipes-extended/bash/bash-3.2.48/bash-fix-error-path-of-getc_with_restart.patch
 create mode 100644 meta/recipes-extended/bash/bash-3.2.48/bash-fix-getc_with_restart.patch

diff --git a/meta/recipes-extended/bash/bash-3.2.48/bash-fix-error-path-of-getc_with_restart.patch b/meta/recipes-extended/bash/bash-3.2.48/bash-fix-error-path-of-getc_with_restart.patch
new file mode 100644
index 0000000..045124f
--- /dev/null
+++ b/meta/recipes-extended/bash/bash-3.2.48/bash-fix-error-path-of-getc_with_restart.patch
@@ -0,0 +1,41 @@
+Upstream-Status: Accepted
+
+When read() returns with ERROR, local_bufused will be set
+to -1; and if we return with local_bufused == -1 left,
+the next time we call getc_with_restart(), the condition
+(local_index == local_bufused || local_bufused == 0)
+will not match, thus we get random data from localbuf[]
+with local_index increased each time, eventually we may
+access data beyond array localbuf[]. Fix it by resetting
+local_index and local_bufused in case of read failure.
+
+Merged by:
+http://git.savannah.gnu.org/cgit/bash.git/commit/input.c?id=ac50fbac377e32b98d2de396f016ea81e8ee9961
+
+Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
+Signed-off-by: Kai Kang <kai.kang@windriver.com>
+---
+ input.c |    7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/input.c
++++ b/input.c
+@@ -78,12 +78,17 @@ getc_with_restart (stream)
+ 	  else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ 	    {
+ 	      if (sh_unset_nodelay_mode (fileno (stream)) < 0)
+-	        return EOF;
++	        {
++	          local_index = 0;
++	          local_bufused = 0;
++		  return EOF;
++		}
+ 	      continue;
+ 	    }
+ 	  else if (local_bufused == 0 || errno != EINTR)
+ 	    {
+ 	      local_index = 0;
++	      local_bufused = 0;
+ 	      return EOF;
+ 	    }
+ 	}
diff --git a/meta/recipes-extended/bash/bash-3.2.48/bash-fix-getc_with_restart.patch b/meta/recipes-extended/bash/bash-3.2.48/bash-fix-getc_with_restart.patch
new file mode 100644
index 0000000..45d93b1
--- /dev/null
+++ b/meta/recipes-extended/bash/bash-3.2.48/bash-fix-getc_with_restart.patch
@@ -0,0 +1,28 @@
+Upstream-Status: Accepted
+
+Let getc_with_restart() handle EAGAIN|EWOULDBLOCK correctly.
+
+Merged by:
+http://git.savannah.gnu.org/cgit/bash.git/commit/input.c?id=3185942a5234e26ab13fa02f9c51d340cec514f8
+
+Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
+Signed-off-by: Kai Kang <kai.kang@windriver.com>
+---
+ input.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/input.c
++++ b/input.c
+@@ -75,6 +75,12 @@ getc_with_restart (stream)
+ 	  local_bufused = read (fileno (stream), localbuf, sizeof(localbuf));
+ 	  if (local_bufused > 0)
+ 	    break;
++	  else if (errno == EAGAIN || errno == EWOULDBLOCK)
++	    {
++	      if (sh_unset_nodelay_mode (fileno (stream)) < 0)
++	        return EOF;
++	      continue;
++	    }
+ 	  else if (local_bufused == 0 || errno != EINTR)
+ 	    {
+ 	      local_index = 0;
diff --git a/meta/recipes-extended/bash/bash_3.2.48.bb b/meta/recipes-extended/bash/bash_3.2.48.bb
index fe04b28..619c3ad 100644
--- a/meta/recipes-extended/bash/bash_3.2.48.bb
+++ b/meta/recipes-extended/bash/bash_3.2.48.bb
@@ -13,6 +13,8 @@ SRC_URI = "${GNU_MIRROR}/bash/bash-${PV}.tar.gz;name=tarball \
            file://build-tests.patch \
            file://test-output.patch \
            file://run-ptest \
+           file://bash-fix-getc_with_restart.patch;striplevel=1 \
+           file://bash-fix-error-path-of-getc_with_restart.patch;striplevel=1 \
           "
 
 SRC_URI[tarball.md5sum] = "338dcf975a93640bb3eaa843ca42e3f8"
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix some bash errors
  2014-04-01  1:59 [PATCH] Fix some bash errors Kai Kang
  2014-04-01  1:59 ` [PATCH] bash-3.2.48: fix error path of getc_with_restart Kai Kang
@ 2014-04-01 10:14 ` Kang Kai
  1 sibling, 0 replies; 3+ messages in thread
From: Kang Kai @ 2014-04-01 10:14 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

On 2014?04?01? 09:59, Kai Kang wrote:
> Fix some errors for bash 3.2.48 by take patches from bash 4.3.
>
> Yong Zhang (1):
>    bash-3.2.48: fix error path of getc_with_restart
>
>   .../bash-fix-error-path-of-getc_with_restart.patch | 41 ++++++++++++++++++++++
>   .../bash-3.2.48/bash-fix-getc_with_restart.patch   | 28 +++++++++++++++
>   meta/recipes-extended/bash/bash_3.2.48.bb          |  2 ++
>   3 files changed, 71 insertions(+)
>   create mode 100644 meta/recipes-extended/bash/bash-3.2.48/bash-fix-error-path-of-getc_with_restart.patch
>   create mode 100644 meta/recipes-extended/bash/bash-3.2.48/bash-fix-getc_with_restart.patch
>

Please ignore it. Thanks.

-- 
Regards,
Neil | Kai Kang


[-- Attachment #2: Type: text/html, Size: 1217 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-01 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-01  1:59 [PATCH] Fix some bash errors Kai Kang
2014-04-01  1:59 ` [PATCH] bash-3.2.48: fix error path of getc_with_restart Kai Kang
2014-04-01 10:14 ` [PATCH] Fix some bash errors Kang Kai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.