Commit Graph

7340 Commits

Author SHA1 Message Date
Kevin Lo
92511d108b Document that listen(2) can fail with EDESTADDRREQ. 2014-07-15 02:21:51 +00:00
Pedro F. Giffuni
dad64c978f libc/gen: small updates to code originating at OpenBSD
arc4random.c
- CVS rev. 1.22
Change arc4random_uniform() to calculate ``2**32 % upper_bound'' as
``-upper_bound % upper_bound''. Simplifies the code and makes it the
same on both ILP32 and LP64 architectures, and also slightly faster on
LP64 architectures by using a 32-bit remainder instead of a 64-bit
remainder.
- CVS rev. 1.23
Spacing

readpassphrase.c
-CVS rev. v 1.24
most obvious unsigned char casts for ctype

Obtained from:	OpenBSD
MFC after:	5 days
2014-07-15 02:21:35 +00:00
Julio Merino
b32cce1f82 Make generation of nslexer.c more robust.
Ensure that lex errors fail the build instead of being silently ignored
due to the piped call.  Also postpone the update of the nslexer.c file
until we are sure we have generated it properly.

These changes fix some very obscure build failures I encountered while
building FreeBSD within a chroot that did not have devfs mounted. The
specific errors looked like:

.../libc.so.7: undefined reference to `_nsyyerror'
.../libc.so.7: undefined reference to `_nsyyin'
.../libc.so.7: undefined reference to `_nsyylex'
.../libc.so.7: undefined reference to `_nsyylineno'
.../libc.so.7: undefined reference to `_nsyytext'

and were caused due to a mangled nslexer.c being linked into libc.
2014-07-14 13:53:10 +00:00
Pedro F. Giffuni
0c02957978 strfmon: reduce unnecessary snprintf.
No need for the snprintf/asprintf dance; use fixed width formats.

Obtained from:	NetBSD (CVS rev. 1.8)
MFC after:	1 week
2014-07-12 15:19:30 +00:00
John Baldwin
9f72c0322c Fix some edge cases with rewinddir():
- In the unionfs case, opendir() and fdopendir() read the directory's full
  contents and cache it.  This cache is not refreshed when rewinddir() is
  called, so rewinddir() will not notice updates to a directory.  Fix this
  by splitting the code to fetch a directory's contents out of
  __opendir_common() into a new _filldir() function and call this from
  rewinddir() when operating on a unionfs directory.
- If rewinddir() is called on a directory opened with fdopendir() before
  any directory entries are fetched, rewinddir() will not adjust the seek
  location of the backing file descriptor.  If the file descriptor passed
  to fdopendir() had a non-zero offset, the rewinddir() will not rewind to
  the beginning.  Fix this by always seeking back to 0 in rewinddir().
  This means the dd_rewind hack can also be removed.

While here, add missing locking to rewinddir().

CR:   	    	https://phabric.freebsd.org/D312
Reviewed by:	jilles
MFC after:	1 week
2014-07-11 16:16:26 +00:00
Konstantin Belousov
a028ee5c9f Implement sysconf(_SC_GETGR_R_SIZE_MAX) and sysconf(_SC_GETPW_R_SIZE_MAX).
Reported by:	Dmitry Sivachenko <trtrmitya@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-07-09 19:12:18 +00:00
Mark Johnston
d3fe75eb62 Fix a typo.
MFC after:	3 days
2014-07-09 01:33:35 +00:00
Sergey Kandaurov
74ba624bf0 [mdoc] Fix previous change. 2014-07-08 12:19:34 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Pedro F. Giffuni
0716c0ff7a minor perf enhancement for UTF-8
Reduce some duplicate code.

Reference:
https://www.illumos.org/issues/628

Obtained from:	Illumos
MFC after:	1 week
2014-07-04 22:39:39 +00:00
Pedro F. Giffuni
f54192cc18 getopt(3): clarify GNU instead of NetBSD.
The manpage and the code for r267745 came from NetBSD but the
option is inspired on GNU.

Reported by:	Ben Kaduk
MFC after:	3 days
2014-07-04 21:06:48 +00:00
Konstantin Belousov
c22de76166 Note that most errors are possible for all syscalls from utimes(2)
family.  Minor wording corrections.

Based on the suggestions by bde.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-07-03 11:19:16 +00:00
Pedro F. Giffuni
6e28368366 regex(3): Add support for \< and \> word delimiters
Solaris and other OSs have support for \< and \> as word
delimiters in utilities like sed(1). These are useful to
have for general compatiblity with Solaris but should be
avoided for portability with other systems, including the
traditional BSDs.

Bump __FreeBSD_version as this is likely to affect some
userland utilities.

Reference:
https://www.illumos.org/issues/516

PR:		bin/153257
Obtained from:	Illumos
MFC after:	1 month
2014-06-30 20:54:25 +00:00
Hajimu UMEMOTO
5d9d18f283 Fix build with WITHOUT_INET6.
Spotted by:	bf
MFC after:	1 week
2014-06-26 14:24:31 +00:00
Hajimu UMEMOTO
17f53388d6 - Exclude loopback address rather than loopback interface.
- style(9)

TODO: When AI_ADDRCONFIG is specified, getaddrinfo() can
be quite slow for system with many interfaces.  We should
have some kernel sysctls to report IPv4/IPv6 status.

Spotted by:	melifaro
MFC after:	1 week
2014-06-26 12:12:18 +00:00
Sergey Kandaurov
521aa90cb8 Document EINVAL as per POSIX.
This also follows r124335-r124336, r225827.

PR:		191382
MFC after:	1 week
Sponsored by:	Nginx, Inc.
2014-06-26 10:21:00 +00:00
Garrett Wollman
775a76844f Catch up with many years of changes:
o Document PF_LOCAL as being an alias for PF_UNIX
o Document POSIX standardization of this interface using AF_*
  constants rather than PF_* constants, and note the three particular
  families which POSIX standardizes.
o Note anticipated POSIX standardization of SOCK_CLOEXEC.
o Delete from listing protocol families that FreeBSD doesn't support
  (in some cases, like PF_PUP, has never supported).
o Add to listing some current protocol families that have been
  introduced in the last decade or so.
o Document the correspondence of PF_* and AF_* constants.

We should probably change the documentation to make the AF_* constants
primary, but this commit does not do so.

Reviewed by:	kevlo@
MFC after:	1 month
2014-06-24 20:23:18 +00:00
Joel Dahl
df2d82e003 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
Hajimu UMEMOTO
290789099b Exclude IPv4 address from doing longest match.
It prevented DNS based load balancing.

MFC after:	1 week
2014-06-23 15:43:27 +00:00
Baptiste Daroussin
8fbf3d50e3 use .Mt to mark up email addresses consistently (part4)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:25:03 +00:00
Andrey A. Chernov
298207c39a Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
to reduce diff and bump OpenBSD patch level to v1.26.

MFC after:      2 weeks
2014-06-22 21:54:57 +00:00
Pedro F. Giffuni
6aa225165f getopt(3): recognize option:: as GNU extension for "optional options".
Also ANSIfy a function declaration.

While here update the OpenBSD patch level in getopt_long.c as we
already have the corresponding change.

Obtained from:	NetBSD
MFC after:	2 weeks
2014-06-22 20:13:57 +00:00
Pedro F. Giffuni
0279beeb0e Revert r267675:
The code doesn't really benefit of using reallocf() in this case.
Also, the realloc() results being assigned temporary variable which
makes blind replacement with reallocf() mostly useless.

Pointed out by:		stefanf, bde
2014-06-21 01:43:56 +00:00
Pedro F. Giffuni
eb0fb866de regex: Make use of reallocf().
Use of reallocf is useful in libraries as we are not certain the
application will exit after NULL.

This somewhat reduces portability but if since you are building
this as part of libc it is likely you have our non-standard
reallocf(3) already.

Reviewed by:	ache
MFC after:	5 days
2014-06-20 15:29:09 +00:00
Hajimu UMEMOTO
cfaa2a0955 Use SOCK_CLOEXEC.
MFC after:	1 week
2014-06-19 11:49:36 +00:00
Konstantin Belousov
11c42bcc54 Add MAP_EXCL flag for mmap(2). It should be combined with MAP_FIXED,
and prevents the request from deleting existing mappings in the
region, failing instead.

Reviewed by:	alc
Discussed with:	jhb
Tested by:	markj, pho (previous version, as part of the bigger patch)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-06-19 05:00:39 +00:00
Konstantin Belousov
8efb419829 The time come to remove the wrapper, most likely, but tidy up it code
instead for now.  Remove spurious blank line, use C89 definition, wrap
long line.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-06-19 04:55:00 +00:00
Pedro F. Giffuni
cd9dcb0307 strptime: add support for %t and %n
Posix strptime() requires support for %t and %n, which were added
to the illumos port.  Curiously we were skipping white spaces by
default in most other cases making %t meaningless.

We now skip spaces in the case of the %e specifier as strftime(3)
explicitly adds a space for the single digit case.

Reference:
http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

Obtained from:	Illumos (Rev. a11c1571b6942161b0186d0588609448066892c2)
MFC after:	3 weeks
2014-06-18 23:34:48 +00:00
Warren Block
a9e1cffd28 Fix syntax error.
PR:		191131
Submitted by:	dan.mcgregor@usask.ca
MFC after:	1 week
2014-06-18 18:31:35 +00:00
Hajimu UMEMOTO
6f63a1142c Retooling addrconfig() to exclude addresses on loopback interfaces
when looking for configured addresses.
This change is based upon the code from the submitter, and made
following changes:
- Exclude addresses assigned on interfaces which are down, like NetBSD
  does.
- Exclude addresses assigned on interfaces which are ifdisabled.

PR:		190824
Submitted by:	Justin McOmie
MFC after:	1 week
2014-06-18 18:07:19 +00:00
Pedro F. Giffuni
3624c75218 stdtime: style(9) fixes.
Obtained from:	illumos
MFC after:	5 days
2014-06-18 02:36:21 +00:00
Pedro F. Giffuni
0413bfcac9 Update license to strptime(3) implementation.
Our strptime(3) implementation was the base for the illumos
implementation and after contacting the author, Kevin Rudy
stated the code is under a 2-Clause BSD License [1]

After reviewing our local changes to the file in question,
the FreeBSD Foundation has agreed that their contributions
to this file are not required to carry clause 3 or 4 so
the file can be relicensed as in Illumos [2].

References:

[1] https://www.illumos.org/issues/357
[2] Illumos Revision:		13222:02526851ba75

Approved:	core (jhb)
Approved:	FreeBSD Foundation (emaste)
MFC after:	4 days
2014-06-16 14:55:09 +00:00
Tijl Coosemans
cdd0ebc93b iconv_open: initialise ci_ilseq_invalid field of _citrus_iconv_shared
struct after allocation with malloc.

iconvlist: reduce a memory leak by copying strings only once.
2014-06-13 08:36:10 +00:00
Tijl Coosemans
3fc3c30a27 Replace malloc+memset with calloc. 2014-06-13 08:28:51 +00:00
Jilles Tjoelker
078cb49070 siglongjmp(): Preserve floating point exception flags on i386 and amd64.
Per POSIX, siglongjmp() shall be equivalent to longjmp() except that it must
match sigsetjmp() instead of setjmp() and except for the effect on the
signal mask. Therefore, it should preserve the floating point exception
flags.

This was fixed for longjmp() and _longjmp() in r180080 and r180081 for amd64
and i386 respectively.
2014-06-09 21:35:36 +00:00
Pietro Cerutti
4c524a4287 - Return NULL and set errno to EINVAL if size is 0 (as required by POSIX).
Update the manpage to reflect this change.
- Always set the current position to the first null-byte when opening in append
mode. This makes the implementation compatible with glibc's. Update the test
suite.

Reported by:	pho
Approved by:	cognet
2014-06-02 13:48:57 +00:00
Benjamin Kaduk
245d93279b Minor mdoc fix
Submitted by:	hrs
Approved by:	hrs (mentor, implicit)
2014-05-30 02:16:28 +00:00
Pedro F. Giffuni
1bb07edbd4 Fix strcasecmp_l() and strncasecmp_l() POSIX 2008 compliance.
POSIX.1-2008 specifies that those two functions should be declared by
including <strings.h>, not <string.h> (the latter only has strcoll_l()
and strxfrm_l()):

http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html

Obtained from:	DragonFlyBSD
Reviewed by:	theraven
MFC after:	2 weeks
2014-05-30 01:09:07 +00:00
Sergey Kandaurov
1d8b56e9a0 mdoc: add missing paragraph macro. 2014-05-29 13:35:13 +00:00
Allan Jude
647efa79a1 Emphasis on 'do not' and 'complement' in the strcspn(3)
Replace literal parentheses with .Po/.Pc

Approved by:	wblock (mentor)
2014-05-27 04:30:56 +00:00
Allan Jude
5538d7a1fc Merge strcspn.3 into strspn.3 and clarify the explaination of what they do
Detach strcspn.3 from the build
Add strcspn.3 to MLINKS do it will be symlinked to strspn.3

Approved by:	eadler (mentor), bcr (mentor)
2014-05-25 18:40:32 +00:00
Benjamin Kaduk
6953d7db5c Correct documentation of the limit on how much memory can be mlock()ed
vm.max_wired is a system-wide limit, not per-process.  Reword the
section to make this more clear.

PR:		docs/189214
Submitted by:	Lawrence Chen (original text)
Approved by:	hrs (mentor)
2014-05-17 03:05:52 +00:00
Konstantin Belousov
ca5e4fe970 Invalidate the cache for the named posix semaphore when opened and
actual file storing the semaphore object is different from the file
created on the first open.  Store the file st_dev and st_ino members
of the struct stat in the semaphore structure on open, and compare
them with the attributes of the opened file to detect unlink and
re-creation.

This fixes an issue of sem_unlink(3) failing to flush the named entry
in the semaphore list for the current or remote process, making
sem_unlink(3) not correctly operating if the unlinked semaphore is
still opened.

Reported by:	Joris Giovannangeli <joris@giovannangeli.fr>
PR:	standards/189353
Reviewed by:	jilles (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-05-10 19:08:07 +00:00
Konstantin Belousov
9b6224b70f Style.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-05-10 18:59:09 +00:00
Peter Holm
e103f5b1c0 msync(2) must return ENOMEM and not EINVAL when the address is outside the
allowed range or when one or more pages are not mapped. This according to
The Open Group Base Specifications Issue 7.

Discussed with:	 attilio, Bruce Evans
Reviewed by:	 alc, Garrett Cooper
Reported by:	 ATF
MFC after:	 2 weeks
Sponsored by:	EMC / Isilon storage division
2014-05-07 08:38:02 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Pedro F. Giffuni
e234ddef95 Revert r265367:
Use of calloc instead of malloc in regex (from OpenBSD).

In this case the change makes no sense since we are using realloc() later.

Reported by:	ache
2014-05-05 18:04:57 +00:00
Pedro F. Giffuni
9d12ca17b5 regex: Use calloc instead of malloc.
Mostly to reduce differences with OpenBSD.

Obtained from:	OpenBSD (CVS rev. 1.17)
MFC after:	3 days
2014-05-05 16:41:15 +00:00
Christian Brueffer
1a2ac459a9 Properly free resources in case of error.
CID:		1007032
Found with:	Coverity Prevent(tm)
MFC after:	2 weeks
2014-05-02 20:41:09 +00:00
Pedro F. Giffuni
eab20bceca regex: Remove some unreachable breaks.
This is based on a much bigger cleanup done in Illumos.

Reference:
https://www.illumos.org/issues/2077

MFC after:	1 week
2014-05-01 23:34:14 +00:00