Bug 465438 - builtins do not report errors on failed file operations
Summary: builtins do not report errors on failed file operations
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: ksh
Version: 5.1
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: BaseOS QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-10-03 10:49 UTC by Tomas Smetana
Modified: 2018-10-19 23:45 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
The ksh builtins fail to report errors on failed file operations, for example, they would not report an error if they were unable to write to a file because of no space on a disk. This could result in data loss, because a user would have no warning that data was not saved. Builtins now provide a proper return code and present an error message to the user if they are unable to complete a file operation. This prevents the user from incorrectly assuming that the file operation has completed correctly in cases where it has not.
Clone Of:
Environment:
Last Closed: 2009-09-02 09:11:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
patch against ksh-20080202 (2.98 KB, patch)
2008-10-15 16:18 UTC, Michal Hlavinka
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:1256 0 normal SHIPPED_LIVE ksh bug fix update 2009-09-01 09:05:54 UTC

Description Tomas Smetana 2008-10-03 10:49:06 UTC
The ksh builtins fail to report errors on failed file operations, e.g.:

echo "something" > /mnt/filesystem/file.txt

Will not report an error and would have zero return code even if "/mnt/filesystem" was full and the file.txt could not be written to.

This problem seems to be present even in the latest upstream version and is caused by not checking the return codes of sfsync/sfwrite/sfclose functions. Excerpt from src/cmd/ksh93/bltins/print.c:

342     else if(n&SF_SHARE)
343     {
344         sfset(outfile,SF_SHARE|SF_PUBLIC,1);
345         sfsync(outfile);
346     }
347     return(exitval);

Note the line 345: if sfsync fails, the builtins print printf or echo would still return no error which may lead to data loss.  The return codes of sfsync/sfclose or sfwrite should not be ignored and any error should be indicated to the user with a proper return code of the command and an error message.

Comment 1 Michal Hlavinka 2008-10-15 16:18:42 UTC
Created attachment 320455 [details]
patch against ksh-20080202

patch against ksh-20080202 (rebased version in oncoming RHEL 5.3)

Comment 2 David Aquilina 2008-11-17 18:51:24 UTC
(In reply to comment #1)
> Created an attachment (id=320455) [details]
> patch against ksh-20080202
> 
> patch against ksh-20080202 (rebased version in oncoming RHEL 5.3)

Customer tested this patch and confirmed that it fixes their problems.

Comment 12 Ruediger Landmann 2009-05-21 03:58:12 UTC
Release note added. If any revisions are required, please set the 
"requires_release_notes" flag to "?" and edit the "Release Notes" field accordingly.
All revisions will be proofread by the Engineering Content Services team.

New Contents:
The ksh builtins fail to report errors on failed file operations, for example, they would not report an error if they were unable to write to a file because of no space on a disk. This could result in data loss, because a user would have no warning that data was not saved. Builtins now provide a proper return code and present an error message to the user if they are unable to complete a file operation. This prevents the user from incorrectly assuming that the file operation has completed correctly in cases where it has not.

Comment 15 errata-xmlrpc 2009-09-02 09:11:01 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1256.html


Note You need to log in before you can comment on or make changes to this bug.