Commit Graph

5840 Commits

Author SHA1 Message Date
Colin Percival
22d725b5d7 Initialize "nconv" to a reasonable value in all code paths. Prior to
this commit, sprintf("%s", "") could fail depending on what happened
to be on the stack.

Found by:	LLVM/Clang Static Checker
2008-08-04 06:55:42 +00:00
Colin Percival
cb8330d036 Set "max" to a reasonable value if BLOCKSIZE has a bogus unit. Prior
to this commit, "env BLOCKSIZE=4X df" prints not only "4X: unknown
blocksize" as expected, but sometimes also "maximum blocksize is 1G"
and "minimum blocksize is 512" depending on what happened to be on
the stack.

Found by:	LLVM/Clang Static Checker
2008-08-04 06:53:13 +00:00
Sean Farley
ee2889cb98 Restructure and use different variables in the tests that involve
environ[0] to be more obvious that environ is not NULL before environ[0]
is tested.  Although I believe the previous code worked, this change
improves code maintainability.

Reviewed by:	ache
MFC after:	3 days
2008-08-03 22:47:23 +00:00
Tom Rhodes
fcae37c9eb Add EAGAIN to the ERRORS list, as found in kern_jail.c.
PR:		125253
Submitted by:	Mateusz Guzik <mjguzik@gmail.com> (original version)
2008-08-03 21:56:58 +00:00
Andrey A. Chernov
89538e75d6 Restored from previous backing out (because that is OpenBSD way, so
assumed to be reviewd by them):
Stir directly from the kernel PRNG, without taking less random pid & time
bytes too (when it is possible).

The difference with OpenBSD code is that they have KERN_ARND sysctl for
that task, while we need to read /dev/random
2008-08-03 20:15:22 +00:00
Remko Lodder
372e9a288d remove whitespace bug (8 spaces into one tab)
Submitted by:	ed
2008-08-02 13:49:12 +00:00
David Schultz
cc4c35b961 Teach fmtcheck() about wint_t, intmax_t, char *, intmax_t *, and
wide string arguments.

Also simplify the code that handles length modifiers and make it
more conservative. For instance, be explicit about the modifiers
allowed for %d, rather than assuming that anything other than L,
q, t, or z implies an int argument.
2008-08-02 06:02:42 +00:00
Sean Farley
3522c38bbe Detect if the application has cleared the environ variable by setting
the first value (environ[0]) to NULL.  This is in addition to the
current detection of environ being replaced, which includes being set to
NULL.  Without this fix, the environment is not truly wiped, but appears
to be by getenv() until an *env() call is made to alter the enviroment.

This change is necessary to support those applications that use this
method for clearing environ such as Dovecot and Postfix.  Applications
such as Sendmail and the base system's env replace environ (already
detected).  While neither of these methods are defined by SUSv3, it is
best to support them due to historic reasons and in lieu of a clean,
defined method.

Add extra units tests for clearing environ using four different methods:
1. Set environ to NULL pointer.
2. Set environ[0] to NULL pointer.
3. Set environ to calloc()'d NULL-terminated array.
4. Set environ to static NULL-terminated array.

Noticed by:	Timo Sirainen

MFC after:	3 days
2008-08-02 02:34:35 +00:00
Ed Schouten
7e7f7ca3c6 Convert popen()'s `pidlist' to a SLIST, for consistency.
I guess the original author of the popen() code didn't want to use our
<sys/queue.h> macro's, because the single linked list macro's didn't
offer O(1) deletion. Because I introduced SLIST_REMOVE_NEXT() some time
ago, we can now use the macro's here.

By converting the code to an SLIST, it is more consistent with other
parts of the C library and the operating system.

Reviewed by:	csjp
Approved by:	philip (mentor, implicit)
2008-07-29 16:29:59 +00:00
John Baldwin
e68d07ff16 Fix a few bugs with the _gettemp() routine which implements mkstemp(),
mkstemps(), and mkdtemp().
- Add proper range checking for the 'slen' parameter passed to mkstemps().
- Try all possible permutations of a template if a collision is encountered.
  Previously, once a single template character reached 'z', it would not wrap
  around to '0' and keep going until it encountered the original starting
  letter.  In the edge case that the randomly generated starting name used
  all 'z' characters, only that single name would be tried before giving up.

PR:		standards/66531
Submitted by:	Jim Luther
Obtained from:	Apple
MFC after:	1 week
2008-07-28 21:18:59 +00:00
Ed Schouten
bd24df89fc Fix the email address formats in some posix_spawn(3) manpages.
It seems I made a small bug when writing some of the posix_spawn(3)
manpages. Remove the redundant "Ed Schouten", which broke the AUTHORS
section.

Approved by:	philip (mentor, implicit)
2008-07-28 09:36:56 +00:00
David Xu
62187b4142 Add manual pages for posix_spawn() functions.
PR:	standards/122051
2008-07-28 02:22:19 +00:00
Andrey A. Chernov
6a05bf3acf Per rwatson's request:
"If you don't get a review within a day or two, I would firmly recommend
backing out the changes"

back out all my changes, i.e. not comes from merging from OpenBSD as
unreviewed by secteam@ yet.
(OpenBSD changes stays in assumption they are reviewd by OpenBSD)

Yes, it means some old bugs returned, like not setted rs_stired = 1 in
arc4random_stir(3) causing double stirring.
2008-07-25 15:42:22 +00:00
Julian Elischer
d12d2ae7a2 Fix cut-n-paste-o
Submitted by:	Kostik Belousov
2008-07-25 01:09:36 +00:00
Andrey A. Chernov
913e28a443 Fixes based on bde's feedback.
1) Unindent and sort variables.
2) Indent struct members.
3) Remove _packed, use guaranteed >128 bytes size and only first 128
bytes from the structure.
4) Reword comment.

Obtained from:  bde
2008-07-22 17:10:18 +00:00
Andrey A. Chernov
ba2c3a6557 Change /dev/urandom to /dev/random since urandom marked as
XXX Deprecated
alias in /sys/dev/random/randomdev.c
2008-07-22 15:25:35 +00:00
Andrey A. Chernov
bc8541b1d1 Use arc4random_uniform(3) since modulo size is not power of 2 2008-07-22 15:08:50 +00:00
Andrey A. Chernov
61d35b6350 In arc4random_uniform() detect simple "power of two" case and
return just (arc4random() % upper_bound)
2008-07-22 12:43:09 +00:00
Andrey A. Chernov
6e4fe40a24 Add arc4random_uniform() function (to avoid "modulo bias")
Obtained from:  OpenBSD
2008-07-22 11:33:49 +00:00
Andrey A. Chernov
85986016ae Increase initially dropped bytes from 512 to 768 (768 is also
suggested in the Ilya Mironov's article). 768 taken from another
research where it treats as default for RC4-drop(768):
http://www.users.zetnet.co.uk/hopwood/crypto/scan/cs.html#RC4-drop

Minor style tweak.
2008-07-22 10:31:29 +00:00
John Baldwin
bf9a8c1d39 Add feature_present(3) to the FBSD 1.1 symbol map. 2008-07-21 22:07:59 +00:00
Andrey A. Chernov
a08f5d95ec 1) Use __packed attr on rdat structure to make it exact 128 bytes.
2) Use gettimeofday() and getpid() only if reading from /dev/urandom
fails or impossible.
3) Discard N bytes on very first initialization only (i.e. don't
discard on re-stir).
4) Reduce N from 1024 to 512 as really suggested in the
"(Not So) Random Shuffles of RC4" paper:
http://research.microsoft.com/users/mironov/papers/rc4full.pdf
2008-07-21 21:57:30 +00:00
Andrey A. Chernov
860c4e582a 1) Update copyright notice.
2) Eliminate "struct arc4_stream *as" arg since only single arg is
possible.
3) Set rs.j = rs.i after arc4random key schedule to be more like arc4
stream cipher.

Obtained from:  OpenBSD
2008-07-21 20:04:32 +00:00
Andrey A. Chernov
531ebdb7b1 Add arc4random_buf to FBSD_1.1 space 2008-07-21 18:03:31 +00:00
Andrey A. Chernov
1c443b9b18 Add arc4random_buf.3 to MLINKS 2008-07-21 14:33:11 +00:00
Andrey A. Chernov
bc6847e225 Implement arc4random_buf() function
Obtained from:  OpenBSD
2008-07-21 13:52:06 +00:00
Andrey A. Chernov
b6634bf8d2 Decrease arc4_count only when needed and with proper bytes amount.
Obtained from:  OpenBSD
2008-07-21 12:44:47 +00:00
Andrey A. Chernov
0761bd1fe1 1) Set stired flag after forced initialization.
2) Increase arc4_count to the limit OpenBSD use.

Submitted by:   Thorsten Glaser <tg@mirbsd.de> (1)
Obtained from:  OpenBSD (2)
2008-07-21 10:31:28 +00:00
Jason Evans
2bb0f7ba54 Enhance arena_chunk_map_t to directly support run coalescing, and use
the chunk map instead of red-black trees where possible.  Remove the
red-black trees and node objects that are obsoleted by this change.  The
net result is a ~1-2% memory savings, and a substantial allocation speed
improvement.
2008-07-18 19:35:44 +00:00
Simon L. B. Nielsen
863a8774c7 Make it more clear what it means that SA_RESTART is set for signal
handlers added with signal(3).

Submitted by:	gnn (slightly modified by me)
MFC after:	1 week
2008-07-17 21:54:23 +00:00
Daniel Gerzo
a624bb23e3 Update the definition of modspecific structure
PR:		docs/125630
2008-07-15 10:06:37 +00:00
Robert Watson
0d01d41007 The libc acl_valid(3) function validates the contents of a POSIX.1e ACL.
This change removes the requirement that an ACL contain no ACL_USER
entries with a uid the same as those of a file, or ACL_GROUP entries
with a gid the same as those of a file.  This requirement is not in the
specification, and not enforced by the kernel's ACL implementation.

Reported by:	Iustin Pop <iusty at k1024 dot org>
MFC after:	1 week
2008-07-13 16:37:51 +00:00
Remko Lodder
5f65888ab9 Update the ktr_header structure, which changed over time.
PR:		125546
Submitted by:	Mateusz Guzik <mjguzik at gmail dot com>
MFC after:	3 days
2008-07-13 13:42:52 +00:00
Brooks Davis
6b794ce8ef Put the _cpuset* symbols in FBSDprivate_1.0 instead of trying to put
nonexistant __cpuset* there.
2008-07-11 15:17:06 +00:00
Daniel Gerzo
5fd5badfa9 - This code was intially obtained from NetBSD, but it's missing licence
statement. Add the one from the current NetBSD version.
- Also bump a date to reflect my content changes I have done in previous
  revision

Approved by:	imp
MFC after:	3 days
2008-07-06 17:03:37 +00:00
Daniel Gerzo
6d05da1dc9 - Add description about a missing return value
PR:		docs/75995
Submitted by:	Tarc <tarc@po.cs.msu.su>
MFC after:	3 days
2008-07-06 12:17:53 +00:00
Daniel Gerzo
408425ce37 - remove superfluous word
- remove contractions

MFC after:	3 days
2008-07-06 11:31:20 +00:00
Daniel Gerzo
05e3085a53 - AI_ALL and AI_V4MAPPED flags are currently not supported
PR:		docs/120248
Submitted by:	Heiko Wundram <wundram (a) beenic.net>
2008-07-01 22:59:20 +00:00
Daniel Gerzo
345f9e9dc7 - Forgot to bump a date after last change 2008-06-30 08:46:09 +00:00
David Schultz
c4014b5086 Fix a bogon in the previous commit and add some missing error checks. 2008-06-29 23:46:06 +00:00
David Schultz
e62e5ff93f Correctly handle malloc() failure. While here, reduce the code size a
bit by removing some calls to the inline function addtype().
2008-06-29 22:54:26 +00:00
David Schultz
07bed96bd3 Factor out the code that builds the argument table. We don't need separate
normal and wide character versions of it.

No functional change.
2008-06-29 22:04:25 +00:00
David Schultz
2591efccfa Reduce the level of duplication between vfprintf() and vfwprintf()
by moving the positional argument handling code to a new file,
printf-pos.c, and moving common definitions to printflocal.h.
No functional change intended.
2008-06-29 21:52:40 +00:00
David Schultz
e5abb5e698 Begin de-spaghettifying the code that handles positional arguments.
In particular, encapsulate the state of the type table in a struct,
and add inline functions to initialize, free, and manipulate that
state. This replaces some ugly macros that made proper error handling
impossible.

While here, remove an unneeded test for NULL and a variable that is
initialized (many times!) but never used. The compiler didn't catch
these because of rampant use of the same variable to mean different
things in different places.

This commit should not cause any changes in functionality.
2008-06-29 21:01:27 +00:00
David Schultz
6b2bbb0465 Make it clearer that it is possible to disable the generation of
SIGPIPE for individual sockets (PR: kern/118626).

While here, s/insure/ensure/.
2008-06-29 17:17:14 +00:00
David Schultz
4110421449 We should also save and restore the MXCSR as on amd64, but detecting
whether the CPU supports SSE or not here is rather odious.
2008-06-28 17:58:06 +00:00
David Schultz
64c2e46650 Two FP-related setjmp/longjmp changes:
1. Save and restore the control part of the MXCSR in addition to the
   i387 control word to ensure that the two are consistent.

   Note that standards don't require longjmp to restore either control
   word, and none of Linux, MacOS X 10.3 and earlier, NetBSD, OpenBSD,
   or Solaris do it. However, it is historical FreeBSD behavior, and
   bde points out that it is needed to make longjmping out of a signal
   handler work properly, given the way FreeBSD clobbers the FPU state
   on signal handler entry.

2. Don't clobber the FPU exception flags in longjmp. C99 requires them
   to remain unchanged.
2008-06-28 17:55:43 +00:00
Daniel Gerzo
aa2a33b4fa - add description of the MLINK error
PR:		docs/123019
MFC after:	3 days
2008-06-26 12:15:38 +00:00
Daniel Gerzo
91bc389e54 Mark the section describing return values with an appropriate section flag.
PR:		docs/122818
MFC after:	3 days
2008-06-26 08:24:59 +00:00
Mike Makonnen
34a087543a Gcc barfs in glob.c when run with -O3. To fix this make g_strchr() work on
and return (const Char *) pointers instead of just (Char *) and get rid of
all the type casting.

PR:		kern/124334
2008-06-26 07:12:35 +00:00