diff options
| -rw-r--r-- | arch/riscv32/bits/syscall.h.in | 3 | ||||
| -rw-r--r-- | ldso/dynlink.c | 15 | ||||
| -rw-r--r-- | src/internal/floatscan.c | 2 | ||||
| -rw-r--r-- | src/malloc/mallocng/glue.h | 2 | ||||
| -rw-r--r-- | src/malloc/mallocng/meta.h | 3 | ||||
| -rw-r--r-- | src/math/logbl.c | 1 | ||||
| -rw-r--r-- | src/stdio/fmemopen.c | 8 | ||||
| -rw-r--r-- | src/stdlib/qsort.c | 2 |
8 files changed, 31 insertions, 5 deletions
diff --git a/arch/riscv32/bits/syscall.h.in b/arch/riscv32/bits/syscall.h.in index dcd0e9f7..7ce5083f 100644 --- a/arch/riscv32/bits/syscall.h.in +++ b/arch/riscv32/bits/syscall.h.in @@ -89,7 +89,6 @@ #define __NR_unshare 97 #define __NR_set_robust_list 99 #define __NR_get_robust_list 100 -#define __NR_nanosleep 101 #define __NR_getitimer 102 #define __NR_setitimer 103 #define __NR_kexec_load 104 @@ -280,12 +279,14 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 #define __NR_process_madvise 440 #define __NR_epoll_pwait2 441 #define __NR_mount_setattr 442 +#define __NR_quotactl_fd 443 #define __NR_landlock_create_ruleset 444 #define __NR_landlock_add_rule 445 #define __NR_landlock_restrict_self 446 diff --git a/ldso/dynlink.c b/ldso/dynlink.c index 715948f4..10471b23 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -41,6 +41,10 @@ static void error_impl(const char *, ...); static void error_noop(const char *, ...); static void (*error)(const char *, ...) = error_noop; +static void set_errno_impl(int); +static void set_errno_noop(int); +static void (*set_errno)(int) = set_errno_noop; + #define MAXP2(a,b) (-(-(a)&-(b))) #define ALIGN(x,y) ((x)+(y)-1 & -(y)) @@ -1424,6 +1428,7 @@ static void reloc_all(struct dso *p) long ret = __syscall(SYS_mprotect, laddr(p, p->relro_start), p->relro_end-p->relro_start, PROT_READ); if (ret != 0 && ret != -ENOSYS) { + set_errno(-ret); error("Error relocating %s: RELRO protection failed: %m", p->name); if (runtime) longjmp(*rtld_fail, 1); @@ -1825,6 +1830,7 @@ void __dls3(size_t *sp, size_t *auxv) /* Activate error handler function */ error = error_impl; + set_errno = set_errno_impl; /* If the main program was already loaded by the kernel, * AT_PHDR will point to some location other than the dynamic @@ -2437,3 +2443,12 @@ static void error_impl(const char *fmt, ...) static void error_noop(const char *fmt, ...) { } + +static void set_errno_impl(int e) +{ + errno = e; +} + +static void set_errno_noop(int e) +{ +} diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index 8c0828fc..b15366b6 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -347,7 +347,7 @@ static long double hexfloat(FILE *f, int bits, int emin, int sign, int pok) else d = c-'0'; if (dc<8) { x = x*16 + d; - } else if (dc < LDBL_MANT_DIG/4+1) { + } else if (dc < (LDBL_MANT_DIG+3)/4+1) { y += d*(scale/=16); } else if (d && !gottail) { y += 0.5*scale; diff --git a/src/malloc/mallocng/glue.h b/src/malloc/mallocng/glue.h index 8c2586fb..c347a4ef 100644 --- a/src/malloc/mallocng/glue.h +++ b/src/malloc/mallocng/glue.h @@ -36,8 +36,10 @@ #define brk(p) ((uintptr_t)__syscall(SYS_brk, p)) #define mmap __mmap +#define munmap __munmap #define madvise __madvise #define mremap __mremap +#define mprotect __mprotect #define DISABLE_ALIGNED_ALLOC (__malloc_replaced && !__aligned_alloc_replaced) diff --git a/src/malloc/mallocng/meta.h b/src/malloc/mallocng/meta.h index 61ec53f9..3a27af64 100644 --- a/src/malloc/mallocng/meta.h +++ b/src/malloc/mallocng/meta.h @@ -129,12 +129,13 @@ static inline int get_slot_index(const unsigned char *p) static inline struct meta *get_meta(const unsigned char *p) { assert(!((uintptr_t)p & 15)); - int offset = *(const uint16_t *)(p - 2); + size_t offset = *(const uint16_t *)(p - 2); int index = get_slot_index(p); if (p[-4]) { assert(!offset); offset = *(uint32_t *)(p - 8); assert(offset > 0xffff); + assert(offset < PTRDIFF_MAX/UNIT); } const struct group *base = (const void *)(p - UNIT*offset - UNIT); const struct meta *meta = base->meta; diff --git a/src/math/logbl.c b/src/math/logbl.c index 962973a7..82dba942 100644 --- a/src/math/logbl.c +++ b/src/math/logbl.c @@ -1,4 +1,5 @@ #include <math.h> +#include <float.h> #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 long double logbl(long double x) { diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index 343e3e3f..38ba9f85 100644 --- a/src/stdio/fmemopen.c +++ b/src/stdio/fmemopen.c @@ -63,13 +63,17 @@ static size_t mwrite(FILE *f, const unsigned char *buf, size_t len) } if (c->mode == 'a') c->pos = c->len; rem = c->size - c->pos; - if (len > rem) len = rem; + if (len > rem) { + errno = ENOSPC; + f->wpos = f->wbase = f->wend = 0; + f->flags |= F_ERR; + len = rem; + } memcpy(c->buf+c->pos, buf, len); c->pos += len; if (c->pos > c->len) { c->len = c->pos; if (c->len < c->size) c->buf[c->len] = 0; - else if ((f->flags&F_NORD) && c->size) c->buf[c->size-1] = 0; } return len; } diff --git a/src/stdlib/qsort.c b/src/stdlib/qsort.c index e4bce9f7..28607450 100644 --- a/src/stdlib/qsort.c +++ b/src/stdlib/qsort.c @@ -71,6 +71,7 @@ static inline void shl(size_t p[2], int n) n -= 8 * sizeof(size_t); p[1] = p[0]; p[0] = 0; + if (!n) return; } p[1] <<= n; p[1] |= p[0] >> (sizeof(size_t) * 8 - n); @@ -83,6 +84,7 @@ static inline void shr(size_t p[2], int n) n -= 8 * sizeof(size_t); p[0] = p[1]; p[1] = 0; + if (!n) return; } p[0] >>= n; p[0] |= p[1] << (sizeof(size_t) * 8 - n); |
