Merge "Sync with upstream openbsd." am: 24062ac661

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2151778

Change-Id: If75e8d185ccc32a57a3b42c3271f4338735fbf72
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2022-07-13 03:14:51 +00:00 committed by Automerger Merge Worker
commit 44c74424bb
11 changed files with 47 additions and 70 deletions

View file

@ -41,7 +41,7 @@ static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
#endif
#ifdef MULTIPLE_THREADS
extern void *__dtoa_locks[];
static void *__dtoa_locks[] = { NULL, NULL };
#endif
Bigint *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: alarm.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/* $OpenBSD: alarm.c,v 1.10 2021/06/24 22:43:31 cheloha Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@ -34,13 +34,12 @@
unsigned int
alarm(unsigned int secs)
{
struct itimerval it, oitv;
struct itimerval *itp = &it;
struct itimerval itv, oitv;
timerclear(&itp->it_interval);
itp->it_value.tv_sec = secs;
itp->it_value.tv_usec = 0;
if (setitimer(ITIMER_REAL, itp, &oitv) == -1)
timerclear(&itv.it_interval);
itv.it_value.tv_sec = secs;
itv.it_value.tv_usec = 0;
if (setitimer(ITIMER_REAL, &itv, &oitv) == -1)
return ((unsigned int) -1);
if (oitv.it_value.tv_usec)
oitv.it_value.tv_sec++;

View file

@ -1,13 +1,13 @@
/*
* Public domain, 2008, Todd C. Miller <millert@openbsd.org>
*
* $OpenBSD: charclass.h,v 1.2 2019/01/25 00:19:25 millert Exp $
* $OpenBSD: charclass.h,v 1.3 2020/10/13 04:42:28 guenther Exp $
*/
/*
* POSIX character class support for fnmatch() and glob().
*/
static struct cclass {
static const struct cclass {
const char *name;
int (*isctype)(int);
} cclasses[] = {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: daemon.c,v 1.7 2010/07/27 22:29:09 marco Exp $ */
/* $OpenBSD: daemon.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -53,7 +53,7 @@ daemon(int nochdir, int noclose)
if (!nochdir)
(void)chdir("/");
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: fnmatch.c,v 1.22 2020/03/13 03:25:45 djm Exp $ */
/* $OpenBSD: fnmatch.c,v 1.23 2020/10/13 04:42:28 guenther Exp $ */
/* Copyright (c) 2011, VMware, Inc.
* All rights reserved.
@ -100,7 +100,7 @@ classmatch(const char *pattern, char test, int foldcase, const char **ep)
{
const char * const mismatch = pattern;
const char *colon;
struct cclass *cc;
const struct cclass *cc;
int rval = RANGE_NOMATCH;
size_t len;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ftok.c,v 1.9 2019/06/28 13:32:41 deraadt Exp $ */
/* $OpenBSD: ftok.c,v 1.10 2022/04/13 16:23:53 millert Exp $ */
/*
* Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
* All rights reserved.
@ -32,11 +32,12 @@
key_t
ftok(const char *path, int id)
{
const unsigned int u_id = id;
struct stat st;
if (stat(path, &st) == -1)
return (key_t)-1;
return (key_t)
((id & 0xff) << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));
((u_id & 0xff) << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: base64.c,v 1.8 2015/01/16 16:48:51 deraadt Exp $ */
/* $OpenBSD: base64.c,v 1.15 2021/10/25 14:41:09 jca Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
@ -46,11 +46,9 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -107,9 +105,9 @@ static const char Pad64 = '=';
end of the data is performed using the '=' character.
Since all base64 input is an integral number of octets, only the
-------------------------------------------------
-------------------------------------------------
following cases can arise:
(1) the final quantum of encoding input is an integral
multiple of 24 bits; here, the final unit of encoded
output will be an integral multiple of 4 characters
@ -123,15 +121,12 @@ static const char Pad64 = '=';
*/
int
b64_ntop(src, srclength, target, targsize)
u_char const *src;
size_t srclength;
char *target;
size_t targsize;
b64_ntop(unsigned char const *src, size_t srclength, char *target,
size_t targsize)
{
size_t datalength = 0;
u_char input[3];
u_char output[4];
unsigned char input[3];
unsigned char output[4];
int i;
while (2 < srclength) {
@ -152,14 +147,14 @@ b64_ntop(src, srclength, target, targsize)
target[datalength++] = Base64[output[2]];
target[datalength++] = Base64[output[3]];
}
/* Now we worry about padding. */
if (0 != srclength) {
/* Get what's left. */
input[0] = input[1] = input[2] = '\0';
for (i = 0; i < srclength; i++)
input[i] = *src++;
output[0] = input[0] >> 2;
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
@ -187,13 +182,10 @@ b64_ntop(src, srclength, target, targsize)
*/
int
b64_pton(src, target, targsize)
char const *src;
u_char *target;
size_t targsize;
b64_pton(char const *src, unsigned char *target, size_t targsize)
{
int tarindex, state, ch;
u_char nextbyte;
unsigned char nextbyte;
char *pos;
state = 0;
@ -207,7 +199,7 @@ b64_pton(src, target, targsize)
break;
pos = strchr(Base64, ch);
if (pos == 0) /* A non-base64 character. */
if (pos == 0) /* A non-base64 character. */
return (-1);
switch (state) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: fputws.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */
/* $OpenBSD: fputws.c,v 1.9 2021/10/24 10:05:23 jsg Exp $ */
/* $NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */
/*-
@ -37,9 +37,7 @@
#include "fvwrite.h"
int
fputws(ws, fp)
const wchar_t * __restrict ws;
FILE * __restrict fp;
fputws(const wchar_t * __restrict ws, FILE * __restrict fp)
{
FLOCKFILE(fp);
_SET_ORIENTATION(fp, 1);

View file

@ -131,7 +131,8 @@ nbf:
flags |= __SNPT;
/*
* Fix up the FILE fields.
* Fix up the FILE fields, and set __cleanup for output flush on
* exit (since we are buffered in some way).
*/
if (mode == _IOLBF)
flags |= __SLBF;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: lsearch.c,v 1.5 2014/07/18 04:16:09 matthew Exp $ */
/* $OpenBSD: lsearch.c,v 1.7 2021/12/08 22:06:28 cheloha Exp $ */
/*
* Copyright (c) 1989, 1993
@ -37,27 +37,27 @@
#include <search.h>
typedef int (*cmp_fn_t)(const void *, const void *);
static void *linear_base(const void *, const void *, size_t *, size_t,
cmp_fn_t, int);
void *
lsearch(const void *key, void *base, size_t *nelp, size_t width,
cmp_fn_t compar)
{
void *element = lfind(key, base, nelp, width, compar);
return(linear_base(key, base, nelp, width, compar, 1));
/*
* Use memmove(3) to ensure the key is copied cleanly into the
* array, even if the key overlaps with the end of the array.
*/
if (element == NULL) {
element = memmove((char *)base + *nelp * width, key, width);
*nelp += 1;
}
return element;
}
void *
lfind(const void *key, const void *base, size_t *nelp, size_t width,
cmp_fn_t compar)
{
return(linear_base(key, base, nelp, width, compar, 0));
}
static void *
linear_base(const void *key, const void *base, size_t *nelp, size_t width,
cmp_fn_t compar, int add_flag)
{
const char *element, *end;
@ -65,20 +65,6 @@ linear_base(const void *key, const void *base, size_t *nelp, size_t width,
for (element = base; element < end; element += width)
if (!compar(key, element)) /* key found */
return((void *)element);
if (!add_flag) /* key not found */
return(NULL);
/*
* The UNIX System User's Manual, 1986 edition claims that
* a NULL pointer is returned by lsearch with errno set
* appropriately, if there is not enough room in the table
* to add a new item. This can't be done as none of these
* routines have any method of determining the size of the
* table. This comment isn't in the 1986-87 System V
* manual.
*/
++*nelp;
memcpy((void *)end, key, width);
return((void *)end);
return NULL;
}
DEF_WEAK(lfind);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: recallocarray.c,v 1.1 2017/03/06 18:44:21 otto Exp $ */
/* $OpenBSD: recallocarray.c,v 1.2 2021/03/18 11:16:58 claudio Exp $ */
/*
* Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net>
*
@ -57,7 +57,7 @@ recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size)
if (newsize <= oldsize) {
size_t d = oldsize - newsize;
if (d < oldsize / 2 && d < getpagesize()) {
if (d < oldsize / 2 && d < (size_t)getpagesize()) {
memset((char *)ptr + newsize, 0, d);
return ptr;
}