nalika / rpms / bash

Forked from rpms/bash 2 years ago
Clone

Blame SOURCES/bash-4.4-fix-buffered_getchar-crash.patch

d77a23
diff -up bash-4.4/input.c.orig bash-4.4/input.c
d77a23
--- bash-4.4/input.c.orig	2022-03-10 10:50:40.046490589 -0300
d77a23
+++ bash-4.4/input.c	2022-03-10 10:51:48.659491601 -0300
d77a23
@@ -530,7 +530,7 @@ bufstream_ungetc(c, bp)
d77a23
      int c;
d77a23
      BUFFERED_STREAM *bp;
d77a23
 {
d77a23
-  if (c == EOF || bp->b_inputp == 0)
d77a23
+  if (c == EOF || bp == 0 || bp->b_inputp == 0)
d77a23
     return (EOF);
d77a23
 
d77a23
   bp->b_buffer[--bp->b_inputp] = c;
d77a23
@@ -561,6 +561,10 @@ buffered_getchar ()
d77a23
 {
d77a23
   CHECK_TERMSIG;
d77a23
 
d77a23
+  if (bash_input.location.buffered_fd < 0 ||
d77a23
+      buffers[bash_input.location.buffered_fd] == 0)
d77a23
+    return EOF;
d77a23
+
d77a23
 #if !defined (DJGPP)
d77a23
   return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
d77a23
 #else