lib/commit: Fix a tmpfile fd leak in static delta processing

I had thought `glnx_link_tmpfile_at()` actually consumed the tmpfile;
it does consume the *path* but not the fd.  In the non-delta path
things were fine since we used the autocleanup.

But the delta code had a tmpfile allocated in its struct that got reused, and
hence leaked the fd. Fix this by making the commit API actually consume the
tmpfile fully, just like the path path.

Closes: #986
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-06-29 21:45:26 -04:00 committed by Atomic Bot
parent 4273e670ea
commit 192e7b888f

View File

@ -156,8 +156,12 @@ _ostree_repo_commit_tmpf_final (OstreeRepo *self,
cancellable, error))
return FALSE;
return glnx_link_tmpfile_at (tmpf, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST,
dest_dfd, tmpbuf, error);
if (!glnx_link_tmpfile_at (tmpf, GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST,
dest_dfd, tmpbuf, error))
return FALSE;
/* We're done with the fd */
glnx_tmpfile_clear (tmpf);
return TRUE;
}
/* Given a dfd+path combination (may be regular file or symlink),