patchThe GNU Bourne-Again SHell - Patches: patch #10512, fd_to_buffered_stream can result...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #10512: fd_to_buffered_stream can result in failures while returning success

Submitter:  Daria Phoebe Brashear <dariaphoebe>
Submitted:  Tue 25 Mar 2025 07:11:24 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Open

Thu 27 Mar 2025 03:33:10 PM UTC, comment #1: 

This gets most of the details wrong, but the problem is, in theory, possible.

The proposed fix happens at the wrong layer of abstraction. I'll put a check in at a higher layer.

Chet Ramey <chet>
Group administrator
Tue 25 Mar 2025 07:11:24 PM UTC, original submission:  

When reading a shell script, bash calls the function default_buffered_input which opens the file and returns the descriptor. The descriptor is then passed to the function fd_to_buffered_stream, which calls fstat against the file-descriptor to determine the size of the file. If the fstat call fails, fd_to_buffered_stream returns a NULL stream. bash always exits with the code from the last executed command and that is initialized to 0. The problem is that if fstat fails due to an EIO, a NULL stream is returned. While b_flag is modified to state the buffer is in error, that information isn't used anywhere and EOF is returned. Whether the script returns success or not is dependent on whether the last command executed succeeds or not.

A patch which fixes this by updating last_command_exit_value is attached.

Daria Phoebe Brashear <dariaphoebe>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by dariaphoebe (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-03-27 chet StatusNone Done
    2025-03-25 dariaphoebe Attached File- Added 0001-io-errors-should-be-reported-from-fd_to_buffered_str.patch, #57062

    Back to the top

    Powered by Savane 3.15-4cd8.
    Corresponding source code