Allow MAP_POPULATE under pledge()

This commit is contained in:
Justine Tunney 2023-12-03 18:00:25 -08:00
parent 53357aa26a
commit cd52c59552
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
6 changed files with 3 additions and 305 deletions

View file

@ -556,22 +556,6 @@ dbg (const char *fmt, ...)
/* Provide support for temporary files. */
#ifndef HAVE_STDLIB_H
# ifdef HAVE_MKSTEMP
int mkstemp (char *template);
# else
char *mktemp (char *template);
# endif
#endif
#ifndef HAVE_UMASK
mode_t
umask (mode_t mask)
{
return 0;
}
#endif
#ifdef VMS
# define DEFAULT_TMPFILE "sys$scratch:gnv$make_cmdXXXXXX.com"
#else
@ -784,260 +768,3 @@ get_tmpfile (char **name)
return file;
}
#if HAVE_TTYNAME && defined(__EMX__)
/* OS/2 kLIBC has a declaration for ttyname(), so configure finds it.
But, it is not implemented! Roll our own. */
char *ttyname (int fd)
{
ULONG type;
ULONG attr;
ULONG rc;
rc = DosQueryHType (fd, &type, &attr);
if (rc)
{
errno = EBADF;
return NULL;
}
if (type == HANDTYPE_DEVICE)
{
if (attr & 3) /* 1 = KBD$, 2 = SCREEN$ */
return (char *) "/dev/con";
if (attr & 4) /* 4 = NUL */
return (char *) "/dev/nul";
if (attr & 8) /* 8 = CLOCK$ */
return (char *) "/dev/clock$";
}
errno = ENOTTY;
return NULL;
}
#endif
#if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI
/* If we don't have strcasecmp() (from POSIX), or anything that can substitute
for it, define our own version. */
int
strcasecmp (const char *s1, const char *s2)
{
while (1)
{
int c1 = (unsigned char) *(s1++);
int c2 = (unsigned char) *(s2++);
if (isalpha (c1))
c1 = tolower (c1);
if (isalpha (c2))
c2 = tolower (c2);
if (c1 != '\0' && c1 == c2)
continue;
return (c1 - c2);
}
}
#endif
#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI
/* If we don't have strncasecmp() (from POSIX), or anything that can
substitute for it, define our own version. */
int
strncasecmp (const char *s1, const char *s2, size_t n)
{
while (n-- > 0)
{
int c1 = (unsigned char) *(s1++);
int c2 = (unsigned char) *(s2++);
if (isalpha (c1))
c1 = tolower (c1);
if (isalpha (c2))
c2 = tolower (c2);
if (c1 != '\0' && c1 == c2)
continue;
return (c1 - c2);
}
return 0;
}
#endif
#ifdef NEED_GET_PATH_MAX
unsigned int
get_path_max (void)
{
static unsigned int value;
if (value == 0)
{
long x = pathconf ("/", _PC_PATH_MAX);
if (x > 0)
value = (unsigned int) x;
else
value = PATH_MAX;
}
return value;
}
#endif
#if !HAVE_MEMPCPY
void *
mempcpy (void *dest, const void *src, size_t n)
{
return (char *) memcpy (dest, src, n) + n;
}
#endif
#if !HAVE_STPCPY
char *
stpcpy (char *dest, const char *src)
{
char *d = dest;
const char *s = src;
do
*d++ = *s;
while (*s++ != '\0');
return d - 1;
}
#endif
#if !HAVE_STRTOLL
# undef UNSIGNED
# undef USE_NUMBER_GROUPING
# undef USE_WIDE_CHAR
# define QUAD 1
# include <strtol.c>
#endif
#if !HAVE_STRERROR
char *
strerror (int errnum)
{
static char msg[256];
#define SETMSG(_e, _m) case _e: strcpy(msg, _m); break
switch (errnum)
{
#ifdef EPERM
SETMSG (EPERM , "Operation not permitted");
#endif
#ifdef ENOENT
SETMSG (ENOENT , "No such file or directory");
#endif
#ifdef ESRCH
SETMSG (ESRCH , "No such process");
#endif
#ifdef EINTR
SETMSG (EINTR , "Interrupted system call");
#endif
#ifdef EIO
SETMSG (EIO , "I/O error");
#endif
#ifdef ENXIO
SETMSG (ENXIO , "No such device or address");
#endif
#ifdef E2BIG
SETMSG (E2BIG , "Argument list too long");
#endif
#ifdef ENOEXEC
SETMSG (ENOEXEC, "Exec format error");
#endif
#ifdef EBADF
SETMSG (EBADF , "Bad file number");
#endif
#ifdef ECHILD
SETMSG (ECHILD , "No child processes");
#endif
#ifdef EAGAIN
SETMSG (EAGAIN , "Try again");
#endif
#ifdef ENOMEM
SETMSG (ENOMEM , "Out of memory");
#endif
#ifdef EACCES
SETMSG (EACCES , "Permission denied");
#endif
#ifdef EFAULT
SETMSG (EFAULT , "Bad address");
#endif
#ifdef ENOTBLK
SETMSG (ENOTBLK, "Block device required");
#endif
#ifdef EBUSY
SETMSG (EBUSY , "Device or resource busy");
#endif
#ifdef EEXIST
SETMSG (EEXIST , "File exists");
#endif
#ifdef EXDEV
SETMSG (EXDEV , "Cross-device link");
#endif
#ifdef ENODEV
SETMSG (ENODEV , "No such device");
#endif
#ifdef ENOTDIR
SETMSG (ENOTDIR, "Not a directory");
#endif
#ifdef EISDIR
SETMSG (EISDIR , "Is a directory");
#endif
#ifdef EINVAL
SETMSG (EINVAL , "Invalid argument");
#endif
#ifdef ENFILE
SETMSG (ENFILE , "File table overflow");
#endif
#ifdef EMFILE
SETMSG (EMFILE , "Too many open files");
#endif
#ifdef ENOTTY
SETMSG (ENOTTY , "Not a typewriter");
#endif
#ifdef ETXTBSY
SETMSG (ETXTBSY, "Text file busy");
#endif
#ifdef EFBIG
SETMSG (EFBIG , "File too large");
#endif
#ifdef ENOSPC
SETMSG (ENOSPC , "No space left on device");
#endif
#ifdef ESPIPE
SETMSG (ESPIPE , "Illegal seek");
#endif
#ifdef EROFS
SETMSG (EROFS , "Read-only file system");
#endif
#ifdef EMLINK
SETMSG (EMLINK , "Too many links");
#endif
#ifdef EPIPE
SETMSG (EPIPE , "Broken pipe");
#endif
#ifdef EDOM
SETMSG (EDOM , "Math argument out of domain of func");
#endif
#ifdef ERANGE
SETMSG (ERANGE , "Math result not representable");
#endif
default: sprintf (msg, "Unknown error %d", errnum); break;
}
return msg;
}
#endif