]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix for EOF while reading a quoted string; allow window size updates during trap...
authorChet Ramey <chet.ramey@case.edu>
Wed, 22 Feb 2023 14:36:28 +0000 (09:36 -0500)
committerChet Ramey <chet.ramey@case.edu>
Wed, 22 Feb 2023 14:36:28 +0000 (09:36 -0500)
CWRU/CWRU.chlog
builtins/evalfile.c
jobs.c
parse.y

index 6fa0ee013a03f39869c286e11a3610b073916710..34539b3be17021ea383c999cd292094b0cb09e61 100644 (file)
@@ -5418,3 +5418,22 @@ parse.y
 doc/{bash.1,bashref.texi}
        - update aliases description based on a bug-bash discussion
        - update description of word splitting behavior when IFS is unset
+
+builtins/evalfile.c
+       - _evalfile: if reading the entire file doesn't return the same
+         number of bytes as requested (the file size), treat this as a read
+         error
+
+                                  2/21
+                                  ----
+parse.y
+       - yylex: if read_token returns < 0, return YYEOF if EOF_Reached = 1.
+         Don't return yacc_EOF because that allows commands to be executed.
+       - grammar: add a production to handle YYEOF, treating it the same as
+         yacc_EOF. Based on a report from
+         Eduardo A. Bustamante López <dualbus@gmail.com>
+
+jobs.c
+       - wait_for: if we're checking for window size changes, allow checks
+         during trap commands while readline is active or `bind -x' command
+         execution. Fix from Koichi Murase <myoga.murase@gmail.com>
index f694794fca82e839d0c54094ec69dac1d36bf9f7..9b6f421541e59e132d54f8c98a0203b08483d0df 100644 (file)
@@ -151,7 +151,7 @@ file_error_and_exit:
       (*errfunc) (_("%s: file is too large"), filename);
       close (fd);
       return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
-    }      
+    }
 
   if (S_ISREG (finfo.st_mode) && file_size <= SSIZE_MAX)
     {
@@ -159,6 +159,8 @@ file_error_and_exit:
       nr = read (fd, string, file_size);
       if (nr >= 0)
        string[nr] = '\0';
+      if (nr != file_size)
+       nr = -1;                /* XXX - didn't get the whole file */
     }
   else
     nr = zmapfd (fd, &string, 0);
diff --git a/jobs.c b/jobs.c
index d6552a3e2aee35d2773af5f195f31d8b78cad864..c0cae92df7ba678140b189dd46dd1aaeafbf21eb 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -3058,8 +3058,16 @@ if (job == NO_JOB)
          else
 #if defined (READLINE)
            /* We don't want to do this if we are running a process during
-              programmable completion or a command bound to `bind -x'. */
-           if (RL_ISSTATE (RL_STATE_COMPLETING|RL_STATE_DISPATCHING|RL_STATE_TERMPREPPED) == 0)
+              programmable completion, but we do want to handle window size
+              changes for traps while readline is active or a command bound
+              to `bind -x'. */
+           if (RL_ISSTATE (RL_STATE_COMPLETING) == 0)
+             if (RL_ISSTATE(RL_STATE_DISPATCHING|RL_STATE_TERMPREPPED) != 0)
+               {
+                 if (check_window_size)
+                   get_new_window_size (0, (int *)0, (int *)0);
+               }
+             else
 #endif
            get_tty_state ();
 
diff --git a/parse.y b/parse.y
index 94a42699973eb1f590711457e3b2eb3899ddcd93..2bfc0c6661fea19f0980fd171f8f007927e2c724 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -466,6 +466,21 @@ inputunit: simple_list simple_list_terminator
                              YYABORT;
                            }
                        }
+       |       error YYEOF
+                       {
+                         global_command = (COMMAND *)NULL;
+                         if (last_command_exit_value == 0)
+                           last_command_exit_value = EX_BADUSAGE;      /* force error return */
+                         if (interactive && parse_and_execute_level == 0)
+                           {
+                             handle_eof_input_unit ();
+                             YYACCEPT;
+                           }
+                         else
+                           {
+                             YYABORT;
+                           }
+                       }
        |       yacc_EOF
                        {
                          /* Case of EOF seen by itself.  Do ignoreeof or
@@ -2459,6 +2474,11 @@ shell_getc (int remove_quoted_newline)
              /* If we want to make read errors cancel execution of any partial
                 line, take out the checks for i == 0 above and set i = 0 if
                 shell_input_line_terminator == READERR. */
+             /* XXX TAG: bash-5.3 austingroup interp 1629 */
+#if defined (FATAL_READERROR)
+             if (shell_input_line_terminator == READERR)
+               i = 0;  /* no-op for now */
+#endif
 
              shell_input_line[i] = '\0';
              break;
@@ -2923,9 +2943,9 @@ yylex (void)
 
   if (current_token < 0)
 #if defined (YYERRCODE) && !defined (YYUNDEF)
-    current_token = YYERRCODE;
+    current_token = EOF_Reached ? YYEOF : YYERRCODE;
 #else
-    current_token = YYUNDEF;
+    current_token = EOF_Reached ? YYEOF : YYUNDEF;
 #endif
 
   return (current_token);