Bug 127842 - Fix wrong mix of fcntl commands and flags
Summary: Fix wrong mix of fcntl commands and flags
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2014-01-29 10:10 PST by Alberto Garcia
Modified: 2014-02-03 00:14 PST (History)
1 user (show)

See Also:

Patch (1.51 KB, patch)
2014-01-29 10:14 PST, Alberto Garcia
no flags Details | Formatted Diff | Diff
Patch (2.49 KB, patch)
2014-01-31 00:35 PST, Alberto Garcia
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alberto Garcia 2014-01-29 10:10:32 PST
Using F_SETFL to set the FD_CLOEXEC flag in the following code is
wrong, the correct command here is F_SETFD.

    while (fcntl(fileDescriptors[i], F_SETFL, FD_CLOEXEC) == -1) {
        if (errno != EINTR) {
Comment 1 Alberto Garcia 2014-01-29 10:14:13 PST
Created attachment 222579 [details]
Comment 2 Sergio Correia (qrwteyrutiyoup) 2014-01-30 16:17:24 PST
Nice catch!

After a quick look, SharedMemory::createHandle() 
[WebKit2/Platform/unix/SharedMemoryUnix.cpp] seems suspicious, as in it does
fcntl(duplicatedHandle, F_SETFD, FD_CLOEXEC | accessModeFile(protection)) == -1).
Seems like it should be F_SETFD for FD_CLOEXEC and F_SETFL for the access mode (O_RDONLY or O_RDWR, in this case), no?
Comment 3 Alberto Garcia 2014-01-31 00:29:55 PST
I think you're right, I'll update the patch.
Comment 4 Alberto Garcia 2014-01-31 00:35:33 PST
Created attachment 222804 [details]
Comment 5 Darin Adler 2014-01-31 12:19:05 PST
Comment on attachment 222804 [details]

Would be much better if these had test coverage.
Comment 6 Alberto Garcia 2014-02-03 00:14:39 PST
Committed r163292: <http://trac.webkit.org/changeset/163292>