Commit Graph

235 Commits

Author SHA1 Message Date
christos 35d355f3ea - new test for strtoi
- namespace protection for strto{i,u}
- separate manpages for strto{i,u} from the ones for strto{u,}l
From: Kamil Rytarowski
2015-05-01 14:17:56 +00:00
joerg c9baa5968d Introduce reallocarr(3) for easy (re)allocation of memory with overflow
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory
leaks on allocation failures and it doesn't depend on malloc(0) != NULL
for correct error checking. Compared to plain realloc, it also avoids
the problem of intermediate integer overflows. The trade-off is the use
of void * to side step C type system with regard to generic pointer to
pointer.
2015-02-17 20:29:20 +00:00
christos 26ba80487b Fix non _REENTRANT build. 2015-01-20 18:31:24 +00:00
christos 718924c8d3 add execvpe, execlpe (reviewed by phone) 2014-09-26 19:28:03 +00:00
manu 724e214f8d Fix argument paddiing for posix_fallocate and fdiscard with gcc 1.x 2014-09-25 15:08:29 +00:00
wiz 87561671c1 defintion -> definition 2014-08-03 19:14:24 +00:00
joerg 3adc1c7681 Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom of
fetching dynamically sized data via sysctl.
2014-06-13 15:45:05 +00:00
christos 13ec391985 CID 273814, don't confuse coverity. 2014-03-20 17:25:23 +00:00
christos 42bc5f633a remove dups 2014-01-16 21:02:30 +00:00
christos a30fe68446 namespace protection for the new err functions 2014-01-16 20:31:18 +00:00
joerg af73a340ec Fix (v)errc/(v)warnc. 2014-01-16 19:16:42 +00:00
joerg fcff7df126 Add cdbr_open_mem. 2013-12-05 21:17:23 +00:00
riastradh 1239c2bb08 Publish explicit_memset and consttime_memequal in userland libc.
Remove the double-underscore from the userland versions, and do the
weak alias dance instead, now that these are public parts of libc.

As discussed on tech-userlevel:

https://mail-index.netbsd.org/tech-userlevel/2013/06/24/msg007843.html
(option 3)
2013-08-28 17:47:07 +00:00
joerg 7efdee83f2 Add strerror_l. 2013-08-19 13:03:12 +00:00
joerg 9c11b12444 Add nl_langinfo_l, catopen_l and wcsftime_l. 2013-08-19 08:03:33 +00:00
christos e72cf68c19 move prototypes to stdio.h 2013-05-04 18:31:47 +00:00
joerg 81d0329e8d Make that to process PATH_LOCALE the first time _find_category is
called. Use this to implement newlocale and provide duplocale/freelocale
as well. Based on patches by Takehiko Nozaki with simplications and fix
for the init order by myself.
2013-04-30 00:45:04 +00:00
joerg 99fac95b50 Store time-specific locale data directly in the locale.
Ad dstrftime_l, strftime_lz and strptime_l.
2013-04-21 17:45:46 +00:00
joerg 9790c07a61 Add scanf_l and wscanf_l families. 2013-04-19 23:32:16 +00:00
joerg e81d3f1ebf Add dummy strcoll_l and strxfrm_l. 2013-04-19 23:28:47 +00:00
joerg 2561b63430 Add explicit locale versions for the printf family. Replace asprintf,
snprintf and sprintf with simple wrappers around the corresponding
va_list functions to reduce code duplication.
2013-04-19 15:22:24 +00:00
joerg 10e0e4a06b Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,
mbrlen_l, mbsinit_l, mbsrtowcs_l, wcrtomb_l, wcsrtombs_l and wctob_l.
2013-04-18 23:24:26 +00:00
joerg 9a7fa6ff3c Add wcstof_l, wcstod_l and wcstold_l. 2013-04-18 22:23:17 +00:00
joerg c99aac45e5 Add strtof_l, strtod_l and strtold_l. 2013-04-18 21:54:10 +00:00
joerg a67fde0356 Add strtol_l and friends. Switch _citrus_bcs_strtol to use plain
strtol_l unless in tools mode. Add note to retire the BCS code on the
next libc major bump.
2013-04-16 21:44:06 +00:00
joerg b7970e3b60 Add wcwidth_l, wcswidth_l and the wctype.h family of *_l functions. 2013-04-16 11:39:13 +00:00
joerg 62898dbb43 Mark __libc_thr_exit_stub as dead. 2013-04-12 18:12:58 +00:00
christos 71d484f921 - Allow libpthread to be dlopened again, by providing libc stubs to libpthread.
- Fail if the dlopened libpthread does pthread_create(). From manu@
- Discussed at length in the mailing lists; approved by core@
- This was chosen as the least intrusive patch that will provide
  the necessary functionality.
XXX: pullup to 6
2013-03-21 16:49:11 +00:00
christos a9bb3b0c76 take care of the signal safe syslog calls which are not exposed. 2012-10-11 17:09:55 +00:00
manu bba80928a8 setcontext() used to be incompatible with -lpthread since it affected
the TLS pointer, therefore wrecking the pthread environement.

Some ports had _UC_TLSBASE flag or equivalent (_UC_UNIQUE on alpha)
that controlled whether setcontext() would change the TLS pointer.
This change let libpthread override setcontext() with its own version
that unsets _UC_TLSBASE, enabling safe usage of setcontext() with
-lpthread.

We also have the following required changes here:
- rename alpha's _UC_UNIQUE into _UC_TLSBASE
- add _UC_TLSBASE definition in header file for all ports
  (powerpc, sh3, sparc and sparc64 lack the implementation for now)
- introduce a libc stub that can be overriden for setcontext()
- modify MD libcs swapcontext() implementations so that they use the
  setcontext() libc stub instead of doing a plain system call.

While we are there:
- document various MD _UC_* flags in header file
- add libc and libpthread tests for swapcontext() behavior
  (hopefully helpful to spot MD problems introduced with this change)

Future work:
- Deciding whether kernel support or _UC_TLSBASE should be added for
  powerpc, sh3, sparc and sparc64 is left to portmasters
  sparc64

Approved by core@
2012-09-12 02:00:51 +00:00
dsl e2ff5b6fd5 I'm fairly sure the libc rules require that arc4random_addrandom,
arc4random_buf, arc4random_stir and arc4random_uniform be weak.
2012-08-20 21:38:09 +00:00
rmind 6461e5c133 Add weak symbol for murmurhash2. 2012-07-09 21:25:46 +00:00
joerg 1907ec3a61 Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) to
depend on new devname_r(3) as heart. Add /dev/pts magic directly to
devname(3). While it can lead to returning non-existing paths, the
behavior is more consistent that way. Drop caching layer in devname(3),
it doesn't buy anything for the common case of having access to the
database. Teach devname(3) proper fallback behavior of scanning /dev.
Create both old-style and new-style database for now in /etc/rc.d/sysdb.
2012-06-03 21:42:44 +00:00
joerg e9c843846e Provide a usable thr_once for !_REENTRANT 2012-06-03 21:27:30 +00:00
christos 2968c226a9 name protection for getpassfd 2012-04-12 22:08:46 +00:00
christos 48c7acbcd7 Add a new getpass implementation that does not mess with signals, and
include getpass_r
2012-04-12 19:36:19 +00:00
christos 2b01a8ad07 PR/46111: Wolfgang Stukenbrock: Add yp_setbindtries(3) so that yp operations
don't hang forever if requested.
2012-03-02 17:27:48 +00:00
joerg 3358b3a30d Make sure that membar_producer gets the proper namespace mangling for libc. 2012-02-15 15:49:46 +00:00
joerg 0a2b758384 Mark _resumecontext as dead. ANSIfy all declarations for it. 2011-09-19 21:24:57 +00:00
joerg 3eb244d801 Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
2011-07-17 20:54:30 +00:00
manu 319b6ef0ee Import xdr_sizeof() from FreeBSD 2011-07-04 07:54:38 +00:00
christos 2587e6e437 add fpgetprec/fpsetprec 2011-03-26 19:51:41 +00:00
christos 2d8f83e77b Fix various vis/unvis issues:
- no need for all the weak symbols
- define a new _VIS_END flag for UNVIS_END so that there are no collisions
  between and vis and unvis flags.
- add bound versions of the vis and unvis functions that take the length of
  the destination buffer. Unlike the OpenBSD ones they return -1 or NULL if
  the buffer is not large enough, instead of silently truncating.
2011-03-12 19:52:45 +00:00
christos 5a87b22ec6 Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.
2010-12-16 18:36:47 +00:00
tron aacd5349be Provide proper namespace protection for rbtree(3) because it is now
used by "libc" internally.
2010-11-17 13:19:32 +00:00
tron 2f85740ecc 1.) Rename internal function __findvar() to __findenvvar().
2.) Add a wrapper function __findenv() which implements the previous
    *internal* interface. It turns out that ld.elf_so(1) and pthread(3)
    both use it.

Stripping e.g. "LD_LIBRARY_PATH" from the environment while running
setuid binaries works again now.
2010-11-14 22:04:36 +00:00
tron fbf4aa1699 Improve and simplify implementation of *env(3) functions:
- Use RB tree to keep track of memory allocated via setenv(3) as
  suggested by Enami Tsugutomo in private e-mail.
  This simplifies the code a lot as we no longer need to keep the size
  of "environ" in sync with an array of allocated environment variables.
  It also makes it possible to free environment variables in unsetenv(3)
  if something has changed the order of the "environ" array.
- Fix a bug in getenv(3) and getenv_r(3) which would return bogus
  results e.g. for " getenv("A=B") " if an environment variable "A"
  with value "B=C" exists.
- Clean up the internal functions:
  - Don't expose the read/write lock for the environment to other parts
    of "libc". Provide locking functions instead.
  - Use "bool" to report success or failure.
  - Use "ssize_t" or "size_t" instead of "int" for indexes.
  - Provide internal functions with simpler interfaces e.g. don't
    combine return values and reference arguments.
  - Don't copy "environ" into an allocated block unless we really need
    to grow it.

Code reviewed by Joerg Sonnenberger and Christos Zoulas, tested by
Joerg Sonnenberger and me. These changes also fix problems in
zsh 4.3.* and pam_ssh according to Joerg.
2010-11-14 18:11:42 +00:00
christos f214ecbad3 forgot to commit this one for two months!
add vdprintf.
2010-11-13 19:41:32 +00:00
jakllsch a34ac1b5ed New vdprintf needs "namespace protection". 2010-09-06 17:49:56 +00:00
joerg b9cf7d31ab Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
2010-04-25 00:54:44 +00:00