Bug 199801 - libfetch should use option letter "e" with fopen() to force O_CLOEXEC instead of calling fcntl() later
Summary: libfetch should use option letter "e" with fopen() to force O_CLOEXEC instead...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Dag-Erling Smørgrav
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-04-30 10:13 UTC by jau
Modified: 2016-01-26 08:40 UTC (History)
2 users (show)

See Also:
des: mfc-stable10+
des: mfc-stable9+


Attachments
Add "e" to fopen() options and remove the fcntl() calls. (771 bytes, patch)
2015-04-30 10:13 UTC, jau
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jau 2015-04-30 10:13:09 UTC
Created attachment 156132 [details]
Add "e" to fopen() options and remove the fcntl() calls.

There are a couple of pointless calls to fcntl() in libfetch
to set FD_CLOEXEC where the easier and more robust approach
would be adding the option letter "e" to fopen() options to
force O_CLOEXEC already at the time of open().
Comment 1 jau 2015-04-30 10:15:41 UTC
This applies also to FreeBSD-10.1.
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-10-16 12:53:56 UTC
A commit references this bug:

Author: des
Date: Fri Oct 16 12:53:22 UTC 2015
New revision: 289420
URL: https://svnweb.freebsd.org/changeset/base/289420

Log:
  Use fopen()'s newfangled "e" flag instead of explicit fcntl() calls.

  PR:		199801
  Submitted by:	Jukka Ukkonen <jau@iki.fi>
  MFC after:	1 week

Changes:
  head/lib/libfetch/file.c
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2015-10-16 12:58:04 UTC
Note that libfetch predates the "e" flag by 14 years, and this particular code predates it by 19 months, so "pointless" is a bit harsh.
Comment 4 commit-hook freebsd_committer freebsd_triage 2016-01-16 20:24:57 UTC
A commit references this bug:

Author: des
Date: Sat Jan 16 20:24:03 UTC 2016
New revision: 294194
URL: https://svnweb.freebsd.org/changeset/base/294194

Log:
  MFH (r280630): remove all traces of SSLv2 support
  MFH (r285141): remove unused variable
  MFH (r288217): correctly check return value from getaddrinfo(3)
  MFH (r289419): fix bugs in HTTPS tunnelling
  MFH (r289420): use fopen()'s "e" mode instead of fcntl for close-on-exec
  MFH (r291453, r291461): use .netrc for http servers and proxies
  MFH (r292330, r292332): reset bufpos to 0 after refilling in chunked mode

  PR:		194483 199801 193740 204771

Changes:
_U  stable/10/
  stable/10/lib/libfetch/common.c
  stable/10/lib/libfetch/fetch.3
  stable/10/lib/libfetch/file.c
  stable/10/lib/libfetch/http.c
  stable/10/usr.bin/fetch/fetch.1
  stable/10/usr.bin/fetch/fetch.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2016-01-26 07:44:47 UTC
A commit references this bug:

Author: des
Date: Tue Jan 26 07:44:27 UTC 2016
New revision: 294776
URL: https://svnweb.freebsd.org/changeset/base/294776

Log:
  MFH (r261233): cleanup
  MFH (r261234): increase buffer size
  MFH (r280630): remove all traces of SSLv2 support
  MFH (r285141): remove unused variable
  MFH (r288217): correctly check return value from getaddrinfo(3)
  MFH (r289419): fix bugs in HTTPS tunnelling
  MFH (r289420): use fopen()'s "e" mode instead of fcntl for close-on-exec
  MFH (r291453, r291461): use .netrc for http servers and proxies
  MFH (r292330, r292332): reset bufpos to 0 after refilling in chunked mode

  PR:		194483 199801 193740 204771

Changes:
_U  stable/9/
_U  stable/9/lib/
_U  stable/9/lib/libfetch/
  stable/9/lib/libfetch/common.c
  stable/9/lib/libfetch/fetch.3
  stable/9/lib/libfetch/file.c
  stable/9/lib/libfetch/http.c
_U  stable/9/usr.bin/
_U  stable/9/usr.bin/fetch/
  stable/9/usr.bin/fetch/fetch.1
  stable/9/usr.bin/fetch/fetch.c