diff options
author | cptpcrd <cptpcrd.git@gmail.com> | 2021-02-07 14:22:21 -0500 |
---|---|---|
committer | Guillem Jover <guillem@hadrons.org> | 2021-02-08 04:02:46 +0100 |
commit | c4fca5bb4fcf8509cb93db6e20314f22994c093b (patch) | |
tree | 52a5ece551e2058bbf3b5191eb57d438f76df584 | |
parent | a1f79978e8c60720d1b4217d3ada638ceb6593a5 (diff) |
closefrom: Handle lowfd < 0 properly
More important if close_range() is going to be used, since casting
negative values to 'unsigned int' might hide the errors.
[guillem@hadrons.org: Minor coding style fix. ]
Signed-off-by: Guillem Jover <guillem@hadrons.org>
-rw-r--r-- | src/closefrom.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/closefrom.c b/src/closefrom.c index be38813..e2e10a8 100644 --- a/src/closefrom.c +++ b/src/closefrom.c @@ -179,6 +179,9 @@ closefrom_procfs(int lowfd) void closefrom(int lowfd) { + if (lowfd < 0) + lowfd = 0; + /* Try the fast method first, if possible. */ #if defined(HAVE_FCNTL_CLOSEM) if (fcntl(lowfd, F_CLOSEM, 0) != -1) |