Commit Graph

26 Commits

Author SHA1 Message Date
Mark Johnston
2528b7e2cb Fix handling of rights on stdio streams, take two.
Split the rights-limiting code into two cases: if one of the input
files isn't a regular file, use caph_limit_stream(3) instead of
open-coding the same logic; if both input files are regular files,
and the initial attempts to map them succeed, we limit the rights on
those files to CAP_MMAP_R.

Add a regression test for PR 234885.

PR:		234885
Reviewed by:	delphij
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19216
2019-02-25 19:47:27 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Xin LI
71024a974d Eliminate unneeded headers. 2011-06-21 20:44:06 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Xin LI
821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI
6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Philippe Charnier
dd99983988 add __unused to succeed at WARNS=6 2008-07-10 13:26:46 +00:00
David Schultz
d48905120d The cmp utility has the questionable feature of using mmap when
comparing regular files.  Add a SIGSEGV handler to make its
behavior less surprising when a read error occurs.  The handler
does not attempt to distinguish errors from file truncation, but
anyone actively modifying a file while trying to compare it
shouldn't even expect something sane to happen.

PR:		45391
Reviewed by:	mike (mentor)
2003-02-26 06:44:46 +00:00
David Malone
f2e8e0dad7 ANSIify function definitions to avoid a warning. 2002-07-28 15:13:17 +00:00
Warner Losh
f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
David Malone
9f5b04e925 Style improvements recommended by Bruce as a follow up to some
of the recent WARNS commits. The idea is:

1) FreeBSD id tags should follow vendor tags.
2) Vendor tags should not be compiled (though copyrights probably should).
3) There should be no blank line between including cdefs and __FBSDIF.
2001-12-10 21:13:08 +00:00
David Malone
5748d9ba6f Cast off_t to long long before printing. Use %ll instead of %q incase
long long and quad_t are not the same.
2001-12-03 20:56:16 +00:00
Mark Murray
6af414cb2e Turn on WARNS=2.
Use __FBSDID().
2001-12-02 23:29:26 +00:00
David Malone
c5250ed112 Make filenames const to avoid a few warnings.
Add FreeBSD tags.

Reviewed by:	cmp
2001-11-05 20:33:40 +00:00
David Malone
60b49f05fa Make cmp work by mmapping chunks of a file, rather than the whole
file at one time.

PR:		24732
Submitted by:	Andrew L. Neporada <andr@dgap.mipt.ru>
MFC after:	2 weeks
2001-11-04 21:31:16 +00:00
Brian Feldman
84ad3d8fc4 Make cmp -s work properly if skip values are given. Also, exit(1)
is now exit(DIFF_EXIT).

PR:		18597
Submitted by:	Anatoly Vorobey <mellon@pobox.com>
Committed at:	Usenix terminal room
2000-06-20 20:28:40 +00:00
Poul-Henning Kamp
78cb0ab485 Oops, byte offset was as off_t. 2000-05-15 08:43:25 +00:00
Poul-Henning Kamp
e03983a32c Let cmp(1) grow in -x option to print differences in contemporarry hex
format rather than the mixed decimal/octal format of -l.
2000-05-15 08:30:43 +00:00
Brian Feldman
ac02226555 Fix improper mmap length paramater which can result in improper behavior
or cmp crashing in specific cases.
1999-07-29 23:26:22 +00:00
Warner Losh
96846ff646 More egcs warning fixes:
o main returns int not void
	o use return 0 at end of main when needed
	o use braces to avoid potentially ambiguous else
	o don't default to type int
	o #ifdef 0 -> #if 0

Reviewed by: obrien and chuckr
1999-04-25 22:37:58 +00:00
Archie Cobbs
fa146c5335 Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]). 1998-12-06 22:58:23 +00:00
Alexander Langer
8abdc2eb40 Sweep through the tree fixing mmap() usage:
- Use MAP_FAILED instead of the constant -1 to indicate
    failure (required by POSIX).
  - Removed flag arguments of '0' (required by POSIX).
  - Fixed code which expected an error return of 0.
  - Fixed code which thought any address with the high bit set
    was an error.
  - Check for failure where no checks were present.

Discussed with:	bde
1997-01-16 21:58:40 +00:00
Joerg Wunsch
c28065c606 Our mmap(2) has a limitation where the `offset' parameter must be
page-aligned.  cmp(1) should know about this flaw, and work around it.

While i was at it, fixed an uninitialized variable as reported by
-Wall.
1997-01-08 12:00:55 +00:00
John Dyson
2ae09ad871 When mmap is used, do an madvise(MADV_SEQUENTIAL) to make things
go much more quickly when file input is really done.  Of course, the
fully cached case will make no difference.
1996-12-11 05:20:20 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00