Fix problems found by Coverity scan.

This commit is contained in:
Milan Broz
2018-07-19 13:53:35 +02:00
parent 1112da76f1
commit 561d9ac2bc
2 changed files with 9 additions and 14 deletions

View File

@@ -640,7 +640,7 @@ int tools_read_json_file(struct crypt_device *cd, const char *file, char **json,
out:
if (block && !quit)
set_int_block(1);
if (fd != STDIN_FILENO)
if (fd >= 0 && fd != STDIN_FILENO)
close(fd);
if (r && buf) {
memset(buf, 0, LUKS2_MAX_MDA_SIZE);
@@ -694,7 +694,7 @@ int tools_write_json_file(struct crypt_device *cd, const char *file, const char
out:
if (block && !quit)
set_int_block(1);
if (fd != STDOUT_FILENO)
if (fd >=0 && fd != STDOUT_FILENO)
close(fd);
return r;
}