From 4936fd862342da3482e891a63d6e8c70f5941478 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 2 Nov 2016 16:02:57 -0200 Subject: [PATCH] AP_Terrain: add O_CLOEXEC in places missing it By opening with O_CLOEXEC we make sure we don't leak the file descriptor when we are exec'ing or calling out subprograms. Right now we currently don't do it so there's no harm, but it's good practice in Linux to have it. --- libraries/AP_Terrain/TerrainIO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_Terrain/TerrainIO.cpp b/libraries/AP_Terrain/TerrainIO.cpp index e87077924c..e1cc536bf1 100644 --- a/libraries/AP_Terrain/TerrainIO.cpp +++ b/libraries/AP_Terrain/TerrainIO.cpp @@ -186,7 +186,7 @@ void AP_Terrain::open_file(void) if (fd != -1) { ::close(fd); } - fd = ::open(file_path, O_RDWR|O_CREAT, 0644); + fd = ::open(file_path, O_RDWR|O_CREAT|O_CLOEXEC, 0644); if (fd == -1) { #if TERRAIN_DEBUG hal.console->printf("Open %s failed - %s\n",