diff options
author | dim <dim@FreeBSD.org> | 2015-02-14 13:12:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-02-14 13:12:03 +0000 |
commit | ff34755926ad8a77e4498e82a23c847d33c6c72d (patch) | |
tree | 32512087a8fc0e78759068f074dd1fcac39ef5c9 /lib/libc | |
parent | 3b7b68ffe74f0538bae62b7a4ba4e448156b9542 (diff) | |
parent | 1cd0dffdca6542739e3aa4c7e5221f0b28d076c4 (diff) | |
download | FreeBSD-src-ff34755926ad8a77e4498e82a23c847d33c6c72d.zip FreeBSD-src-ff34755926ad8a77e4498e82a23c847d33c6c72d.tar.gz |
Merge ^/head r278499 through r278755.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/_spinlock_stub.c | 41 | ||||
-rw-r--r-- | lib/libc/include/libc_private.h | 5 | ||||
-rw-r--r-- | lib/libc/nls/msgcat.c | 1 | ||||
-rw-r--r-- | lib/libc/regex/regcomp.c | 17 | ||||
-rw-r--r-- | lib/libc/sys/interposing_table.c | 2 |
5 files changed, 44 insertions, 22 deletions
diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c index 47bbfeb..fddfc1b 100644 --- a/lib/libc/gen/_spinlock_stub.c +++ b/lib/libc/gen/_spinlock_stub.c @@ -33,51 +33,48 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include "spinlock.h" +#include "libc_private.h" long _atomic_lock_stub(volatile long *); void _spinlock_stub(spinlock_t *); void _spinunlock_stub(spinlock_t *); void _spinlock_debug_stub(spinlock_t *, char *, int); -/* - * Declare weak definitions in case the application is not linked - * with libpthread. - */ __weak_reference(_atomic_lock_stub, _atomic_lock); -__weak_reference(_spinlock_stub, _spinlock); -__weak_reference(_spinunlock_stub, _spinunlock); -__weak_reference(_spinlock_debug_stub, _spinlock_debug); -/* - * This function is a stub for the _atomic_lock function in libpthread. - */ long _atomic_lock_stub(volatile long *lck __unused) { return (0L); } +__weak_reference(_spinlock, _spinlock_debug); +#pragma weak _spinlock +void +_spinlock(spinlock_t *lck) +{ -/* - * This function is a stub for the spinlock function in libpthread. - */ + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock]) + (lck); + +} + +#pragma weak _spinlock void -_spinlock_stub(spinlock_t *lck __unused) +_spinunlock(spinlock_t *lck) { + + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock]) + (lck); + } -/* - * This function is a stub for the spinunlock function in libpthread. - */ void -_spinunlock_stub(spinlock_t *lck __unused) +__libc_spinlock_stub(spinlock_t *lck __unused) { } -/* - * This function is a stub for the debug spinlock function in libpthread. - */ void -_spinlock_debug_stub(spinlock_t *lck __unused, char *fname __unused, int lineno __unused) +__libc_spinunlock_stub(spinlock_t *lck __unused) { } diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index bfcd3d0..71fc8df 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -95,6 +95,9 @@ do { \ _SPINUNLOCK(&__stdio_thread_lock); \ } while (0) +void __libc_spinlock_stub(struct _spinlock *); +void __libc_spinunlock_stub(struct _spinlock *); + /* * Indexes into the pthread jump table. * @@ -216,6 +219,8 @@ enum { INTERPOS_write, INTERPOS_writev, INTERPOS__pthread_mutex_init_calloc_cb, + INTERPOS_spinlock, + INTERPOS_spinunlock, INTERPOS_MAX }; diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index 2859916..0cba460 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); np->name = strdup(n); \ np->path = NULL; \ np->catd = NLERR; \ + np->refcount = 0; \ np->lang = (l == NULL) ? NULL : \ strdup(l); \ np->caterrno = e; \ diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 2ecb88c..ae92f6a 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -192,6 +192,7 @@ regcomp(regex_t * __restrict preg, struct parse *p = &pa; int i; size_t len; + size_t maxlen; #ifdef REDEBUG # define GOODFLAGS(f) (f) #else @@ -213,7 +214,23 @@ regcomp(regex_t * __restrict preg, g = (struct re_guts *)malloc(sizeof(struct re_guts)); if (g == NULL) return(REG_ESPACE); + /* + * Limit the pattern space to avoid a 32-bit overflow on buffer + * extension. Also avoid any signed overflow in case of conversion + * so make the real limit based on a 31-bit overflow. + * + * Likely not applicable on 64-bit systems but handle the case + * generically (who are we to stop people from using ~715MB+ + * patterns?). + */ + maxlen = ((size_t)-1 >> 1) / sizeof(sop) * 2 / 3; + if (len >= maxlen) { + free((char *)g); + return(REG_ESPACE); + } p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ + assert(p->ssize >= len); + p->strip = (sop *)malloc(p->ssize * sizeof(sop)); p->slen = 0; if (p->strip == NULL) { diff --git a/lib/libc/sys/interposing_table.c b/lib/libc/sys/interposing_table.c index d303779..0fd6c75 100644 --- a/lib/libc/sys/interposing_table.c +++ b/lib/libc/sys/interposing_table.c @@ -73,6 +73,8 @@ interpos_func_t __libc_interposing[INTERPOS_MAX] = { SLOT(write, __sys_write), SLOT(writev, __sys_writev), SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub), + SLOT(spinlock, __libc_spinlock_stub), + SLOT(spinunlock, __libc_spinunlock_stub), }; #undef SLOT |