coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] truncate: don't leak a file descriptor with --ref=PIPE


From: Pádraig Brady
Subject: Re: [PATCH] truncate: don't leak a file descriptor with --ref=PIPE
Date: Sat, 04 Aug 2012 10:37:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 08/04/2012 10:06 AM, Jim Meyering wrote:
> FYI,
> 
>>From 0ee727e612ae202e5b47e39062f6604d65a76074 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <address@hidden>
> Date: Sat, 4 Aug 2012 11:02:40 +0200
> Subject: [PATCH] truncate: don't leak a file descriptor with --ref=PIPE
> 
> * src/truncate.c (main): For a user who makes the mistake of
> using a non-seekable file as a reference for the desired length,
> truncate would open that file, attempt to seek to its end, but
> upon seek failure would neglect to close the file descriptor.
> Reverse conjuncts, so the close is unconditional.
> Spotted by coverity.

Cool.
Not worth a news entry because we exit() right after
(as file_size will be left at -1 in this case).

Hmm, but I just noticed that close() may clear
the errno of an lseek() failure, so we'd get
the classic "Error: success" in this case?

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]