main: fix fd validity check

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-07-25 17:56:30 +02:00
parent 45b8bb85d4
commit 4e32e8907d
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

2
main.c
View File

@ -2858,7 +2858,7 @@ create_file (struct ovl_data *lo, int dirfd, const char *path, uid_t uid, gid_t
if (uid == lo->uid && gid == lo->gid) if (uid == lo->uid && gid == lo->gid)
{ {
ret = TEMP_FAILURE_RETRY (openat (get_upper_layer (lo)->fd, path, flags, mode)); ret = TEMP_FAILURE_RETRY (openat (get_upper_layer (lo)->fd, path, flags, mode));
if (ret == 0) if (ret >= 0)
return ret; return ret;
/* if it fails (e.g. there is a whiteout) then fallback to create it in /* if it fails (e.g. there is a whiteout) then fallback to create it in
the working dir + rename. */ the working dir + rename. */