Commit Graph

48 Commits

Author SHA1 Message Date
Bryan Drewery
814f2cd84c Fix 'jot -r 0 start end' to work.
This allows an endless stream of random data within the given bounds.
It already worked if a seed was provided as the 4th argument but not
if one was left out.

In collaboration with:	jhb
MFC after:		2 weeks
Relnotes:		yes
2019-04-16 00:41:22 +00:00
Mariusz Zaborski
377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Mariusz Zaborski
7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +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
Conrad Meyer
1532e6565c Capsicum support for jot(1)
Limit descriptors and enter capability mode in jot(1).

Submitted by:	brueffer (earlier version)
Reviewed by:	emaste, jonathan (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D1345
2016-10-19 21:50:57 +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
Brian Somers
9c24af3d15 Fix stuttering sequences and reverse ranges
PR:		123635
Submitted by:	Ulrich Spörlein, uqs at spoerlein dot net
2010-06-02 07:47:29 +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
Brian Somers
58a654f664 Fix some uninitialise variables.
PR:		136383
Submitted by:	Ulrich Spoerlein - uqs at spoerlein dot net
Approved by:	re (kib)
MFC after:	3 weeks
2009-07-08 10:16:16 +00:00
Xin LI
82417e9f03 Use explicit braces to avoid ambiguous else. 2006-12-09 15:23:20 +00:00
Diomidis Spinellis
f88b45d7df Prevent buffer overflow when forcibly terminating an escape character.
Obtained from:	OpenBSD
Note: In the case of a full buffer the OpenBSD implementation will
leave in the format string an invalid escape sequence.  This appears
to be harmless with our C library, but according to C99 this can
cause undefined behavior.

MFC after:      2 weeks
2006-12-03 17:50:21 +00:00
Diomidis Spinellis
34785a9fc0 Correct handling of format strings with escaped % specifications.
Note: It would be nice to be able to implement getformat() using
fmtcheck(3), but fmtcheck does not distinguish between signed and
unsigned types, a facility jot needs to perform range checks on its
output.

Submitted by:   Per Kristian Hove
MFC after:	2 weeks
2006-12-03 17:05:04 +00:00
Diomidis Spinellis
3241f274f1 Style facelift.
- Reduce the number of global variables
- Make global objects static
- Use bool consistently
- Sort getopt arguments and their processing
- Add function comments
- Change notlast != 0 into !last
2006-11-06 15:58:35 +00:00
Diomidis Spinellis
7d71f06cb4 Use a more sensible default of 1 or -1 when only the start and
end values are specified.

PR:		bin/68981
Submitted by:	Stefan `Sec` Zehl
MFC after:	2 weeks
2006-11-06 15:11:50 +00:00
Diomidis Spinellis
d129c68a14 Do What I Mean when the user asks for random integers or characters.
Up to now jot would fail to generate the last character in the range
or skew the integer distribution in a way that would generate the numbers
in the range's limits with half the probability of the rest.

This modification fixes the program, rather than documenting the
strange behavior, as suggested in docs/54879.

Also, correctly specify the range of random(3).

PR:		docs/54879
MFC after:	2 weeks
2006-11-06 13:55:11 +00:00
Diomidis Spinellis
fee14f30e9 Avoid negative array indices: an empty string can also be used
to specify a default value.
2006-11-06 11:03:43 +00:00
Diomidis Spinellis
a26a66124e Restore jot's ability to use a seed for producing a deterministic
sequence of random numbers.
This functionality was lost in revision 1.9 when the random number
generator was switched to arc4random.

PR:		docs/54879
MFC after:	2 weeks
2006-11-06 10:30:29 +00:00
Diomidis Spinellis
55f965ae6a Replace obscure aliases through pointers with plain variables.
MFC after:	2 weeks
2006-11-06 09:15:21 +00:00
Diomidis Spinellis
d737ec1ad4 Merge code in common cases.
Verified by:	New regression tests in tools/regression/usr.bin/jot
MFC after:	2 weeks
2006-11-06 08:47:41 +00:00
Diomidis Spinellis
afe53a4950 Replace opaque numeric bit flag values with #defined identifiers.
While there, add some missing FALLTHROUGH comments.

Verified with:	cmp(1) on the executable
MFC after:	2 weeks
2006-11-06 07:26:16 +00:00
Tim J. Robbins
911a3ff97b Avoid passing negative values to <ctype.h> functions on machines with
signed chars.
2004-07-16 05:10:46 +00:00
David Schultz
bbc7056be8 Fix jot so that 'jot -r -w %d 1 1 4' never prints 4. Previously, it
would print it with probability 1/2**32.  It seems that the correct
behavior is to print 4 with probability 1/4, but I'd like to avoid
breaking POLA until all the range inconsistencies in jot can be fixed
in one pass.  See PR for details.

PR:		54878
Submitted by:	David Brinegar <jot.3.brinegar@spamgourmet.com>
2003-08-01 16:23:24 +00:00
Mike Barcroft
0ad736e62b Don't depend on pollution in <limits.h> for the definition of
<stdint.h> macros.
2002-07-05 15:58:27 +00:00
David E. O'Brien
e026a48c34 Consistently use FBSDID 2002-06-30 05:25:07 +00:00
Juli Mallett
9ed3737fca Remove local prototype for main(). 2002-06-15 11:28:09 +00:00
Juli Mallett
cf0def9349 Protoize. Remove un-needed cast to char in switch of getopt(3)'s return value.
FBSDID.
2002-06-15 11:26:25 +00:00
Warner Losh
f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
Garrett Wollman
07321a183e Actually, arc4random() returns a uint32_t, not an int. Use the correct
constant, just in case uint32_t turns into a `short' ten years from now.
If this is MFC'd it will be necessary to hard-code the constant since
-stable doesn't have UINT32_MAX.
2001-11-08 22:01:35 +00:00
Andrew Gallatin
f776d8e82b fix jot -r on 64-bit platforms by teaching it that arc4random outputs
an int, not a long

Submitted by: Paul Herman <pherman@frenchfries.net>
PR#: alpha/31859
2001-11-08 20:49:24 +00:00
Dima Dorfman
f878e83f9d Replace the cast I removed in rev. 1.16 with a slightly less evil one
(well, at least one that gcc doesn't complain about).  This fixes -r,
which rev. 1.16 broke.

Submitted by:	bde
2001-05-29 23:35:18 +00:00
Dima Dorfman
edd7b2674d Silence warnings and compile with WARNS=2 on i386 and alpha. 2001-05-28 00:55:50 +00:00
Dima Dorfman
15ba0427d3 Miscellaneous cleanups; sync to OpenBSD as much as feasible.
Noteworthy changes include:
 * Use getopt(3).
 * Fix overflows in -b and -w options.
 * Use strlcpy(3) and snprintf(3) in favor of strcpy(3) and
   sprintf(3), respectively.  Also check return values of the former
   two.
 * Fix lots of other gratuitous differences with OpenBSD.

Obtained from:	OpenBSD
2001-05-27 21:08:19 +00:00
Kris Kennaway
612740bdcf Don't call printf with no format string. 2000-07-10 06:02:13 +00:00
Sheldon Hearn
5249bd84d6 Back out rev 1.11, about which bde had concerns, and instead implement
appropriate bounds-checking and typecasts based on our knowledge of
the desired conversion format specifier.

Simplify diagnostics and take care to print the correct conversion
format specifier when %l is involved.
2000-01-06 15:37:37 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Sheldon Hearn
d8d41a0985 Don't dump core for a known, documented bug.
PR:	12611
Reviewed by:	markm
1999-07-22 17:33:11 +00:00
Sheldon Hearn
8db8a33bb9 Improve printf(3) conversion specifier parsing so that silly formats
aren't allowed and the right casts can be used for printf() statements.

Document the conversion specifier limitations and the fact that
arithmetic overflow causes a fatal error.

PR:	12611
Reported by:	Frode Vatvedt Fjeld <frodef@acm.org>
Reviewed by:	bde
1999-07-22 17:11:59 +00:00
Kris Kennaway
4b9cb490c3 Correct an error in a manpage example, add -Wall -W to Makefile (no
warnings given) and modify source to use arc4random() instead of random().

Reviewed by:	ache
1999-05-13 12:18:24 +00:00
Philippe Charnier
d078aa135c Mdoc'ify man page. 1997-11-03 07:45:33 +00:00
Philippe Charnier
7bd7ad50aa Use err(3) instead of local redefinition. Add usage(). 1997-07-15 09:59:30 +00:00
Andrey A. Chernov
687ee69a2a Remove srandomdev fallback code 1997-06-14 00:27:03 +00:00
Andrey A. Chernov
5790155e89 Use srandomdev() now
Fix error with begin variable calculation
1997-03-30 23:13:59 +00:00
Andrey A. Chernov
28c4ca5ce6 Fix srandom arg type according to Lite2 1997-03-11 14:06:52 +00:00
Andrey A. Chernov
9d288406f5 Add ^ getpid() to make more random results for subsequent calling.
Add proper type casting to random calls

Should go into 2.2
1997-03-08 11:40:15 +00:00
Joerg Wunsch
e29b080f61 >Number: 917
>Category:       bin
>Synopsis:       -s option in jot is broken
1995-12-29 12:18:46 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00