rcolebaugh / rpms / bash

Forked from rpms/bash 2 years ago
Clone

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

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