[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-ddrescue] [PATCH 6/7] [clang-tidy] Use O_CLOEXEC when opening files
From: |
Rosen Penev |
Subject: |
[Bug-ddrescue] [PATCH 6/7] [clang-tidy] Use O_CLOEXEC when opening files |
Date: |
Mon, 14 Oct 2019 13:59:45 -0700 |
Found with android-cloexec-open
This is mainly useful with SELinux is my understanding. Requires POSIX 2008.
Signed-off-by: Rosen Penev <address@hidden>
---
main.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/main.cc b/main.cc
index de0071f..55d53fb 100644
--- a/main.cc
+++ b/main.cc
@@ -286,7 +286,7 @@ int do_fill( const long long offset, Domain & domain,
if( fillbook.domain().empty() ) return empty_domain();
if( fillbook.read_only() ) return not_writable( mapname );
- const int ides = open( iname, O_RDONLY | O_BINARY );
+ const int ides = open( iname, O_RDONLY | O_BINARY | O_CLOEXEC );
if( ides < 0 )
{ show_error( "Can't open input file", errno ); return 1; }
if( !fillbook.read_buffer( ides ) )
@@ -332,7 +332,7 @@ int do_generate( const long long offset, Domain & domain,
return 1;
}
- const int ides = open( iname, O_RDONLY | O_BINARY );
+ const int ides = open( iname, O_RDONLY | O_BINARY | O_CLOEXEC );
if( ides < 0 )
{ show_error( "Can't open input file", errno ); return 1; }
const long long insize = lseek( ides, 0, SEEK_END );
@@ -348,7 +348,7 @@ int do_generate( const long long offset, Domain & domain,
}
if( genbook.read_only() ) return not_writable( mapname );
- const int odes = open( oname, O_RDONLY | O_BINARY );
+ const int odes = open( oname, O_RDONLY | O_BINARY | O_CLOEXEC );
if( odes < 0 )
{ show_error( "Can't open output file", errno ); return 1; }
if( lseek( odes, 0, SEEK_SET ) )
@@ -398,7 +398,7 @@ void about_to_copy( const Rescuebook & rescuebook, const
char * const iname,
if( ask || verbosity >= 2 )
{
device_id_and_size( insize, ides, iid );
- const int odes = open( oname, O_RDONLY );
+ const int odes = open( oname, O_RDONLY | O_CLOEXEC );
if( odes >= 0 )
{
device_id_and_size( lseek( odes, 0, SEEK_END ), odes, oid );
--
2.17.1