Browse Source

compat updates, add recallocarray and freezero

OPENBSD_6_1
Brent Cook 7 years ago
committed by Brent Cook
parent
commit
aa4af26849
6 changed files with 53 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +8
    -0
      compat/Makefile.am
  3. +32
    -0
      compat/freezero.c
  4. +3
    -1
      configure.ac
  5. +8
    -0
      include/stdlib.h
  6. +1
    -0
      update.sh

+ 1
- 0
.gitignore View File

@ -42,6 +42,7 @@ compat/imsg-buffer.c
compat/imsg.c compat/imsg.c
compat/md5.c compat/md5.c
compat/reallocarray.c compat/reallocarray.c
compat/recallocarray.c
compat/sha2.c compat/sha2.c
compat/strlcat.c compat/strlcat.c
compat/strlcpy.c compat/strlcpy.c


+ 8
- 0
compat/Makefile.am View File

@ -71,6 +71,10 @@ if !HAVE_CLOSEFROM
libcompat_la_SOURCES += closefrom.c libcompat_la_SOURCES += closefrom.c
endif endif
if !HAVE_FREEZERO
libcompat_la_SOURCES += freezero.c
endif
if !HAVE_IMSG if !HAVE_IMSG
libcompat_la_SOURCES += imsg.c libcompat_la_SOURCES += imsg.c
libcompat_la_SOURCES += imsg-buffer.c libcompat_la_SOURCES += imsg-buffer.c
@ -84,6 +88,10 @@ if !HAVE_REALLOCARRAY
libcompat_la_SOURCES += reallocarray.c libcompat_la_SOURCES += reallocarray.c
endif endif
if !HAVE_RECALLOCARRAY
libcompat_la_SOURCES += recallocarray.c
endif
if !HAVE_SETPROCTITLE if !HAVE_SETPROCTITLE
libcompat_la_SOURCES += setproctitle.c libcompat_la_SOURCES += setproctitle.c
endif endif


+ 32
- 0
compat/freezero.c View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
* Copyright (c) 2008 Damien Miller <djm@openbsd.org>
* Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <string.h>
#include <stdlib.h>
void
freezero(void *ptr, size_t sz)
{
/* This is legal. */
if (ptr == NULL)
return;
explicit_bzero(ptr, sz);
free(ptr);
}

+ 3
- 1
configure.ac View File

@ -39,7 +39,7 @@ CHECK_OS_OPTIONS
CHECK_CRYPTO_COMPAT CHECK_CRYPTO_COMPAT
# check functions that are expected to be in libc # check functions that are expected to be in libc
AC_CHECK_FUNCS([asprintf closefrom daemon memmem poll reallocarray])
AC_CHECK_FUNCS([asprintf closefrom daemon freezero memmem poll reallocarray recallocarray])
AC_CHECK_FUNCS([setproctitle setgroups]) AC_CHECK_FUNCS([setproctitle setgroups])
AC_CHECK_FUNCS([setregid setresgid setreuid setresuid]) AC_CHECK_FUNCS([setregid setresgid setreuid setresuid])
AC_CHECK_FUNCS([strlcat strlcpy strtonum sysconf]) AC_CHECK_FUNCS([strlcat strlcpy strtonum sysconf])
@ -95,11 +95,13 @@ AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes]) AM_CONDITIONAL([HAVE_CLOSEFROM], [test "x$ac_cv_func_closefrom" = xyes])
AM_CONDITIONAL([HAVE_DAEMON], [test "x$ac_cv_func_daemon" = xyes]) AM_CONDITIONAL([HAVE_DAEMON], [test "x$ac_cv_func_daemon" = xyes])
AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes]) AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes])
AM_CONDITIONAL([HAVE_FREEZERO], [test "x$ac_cv_func_freezero" = xyes])
AM_CONDITIONAL([HAVE_IFADDRS_H], [test "x$ac_cv_header_ifaddrs_h" = xyes]) AM_CONDITIONAL([HAVE_IFADDRS_H], [test "x$ac_cv_header_ifaddrs_h" = xyes])
AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes]) AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes])
AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes]) AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes])
AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
AM_CONDITIONAL([HAVE_RECALLOCARRAY], [test "x$ac_cv_func_recallocarray" = xyes])
AM_CONDITIONAL([HAVE_SETGROUPS], [test "x$ac_cv_func_setgroups" = xyes]) AM_CONDITIONAL([HAVE_SETGROUPS], [test "x$ac_cv_func_setgroups" = xyes])
AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes]) AM_CONDITIONAL([HAVE_SETRESGID], [test "x$ac_cv_func_setresgid" = xyes])
AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes]) AM_CONDITIONAL([HAVE_SETRESUID], [test "x$ac_cv_func_setresuid" = xyes])


+ 8
- 0
include/stdlib.h View File

@ -24,10 +24,18 @@ uint32_t arc4random_uniform(uint32_t);
int daemon(int nochdir, int noclose); int daemon(int nochdir, int noclose);
#endif #endif
#ifndef HAVE_FREEZERO
void freezero(void *ptr, size_t sz);
#endif
#ifndef HAVE_REALLOCARRAY #ifndef HAVE_REALLOCARRAY
void *reallocarray(void *, size_t, size_t); void *reallocarray(void *, size_t, size_t);
#endif #endif
#ifndef HAVE_RECALLOCARRAY
void *recallocarray(void *, size_t, size_t, size_t);
#endif
#ifndef HAVE_SETPROCTITLE #ifndef HAVE_SETPROCTITLE
void compat_init_setproctitle(int argc, char *argv[]); void compat_init_setproctitle(int argc, char *argv[]);
void setproctitle(const char *fmt, ...); void setproctitle(const char *fmt, ...);


+ 1
- 0
update.sh View File

@ -45,6 +45,7 @@ for i in explicit_bzero.c strlcpy.c strlcat.c; do
$CP_LIBC $libc_src/string/$i compat $CP_LIBC $libc_src/string/$i compat
done done
$CP_LIBC $libc_src/stdlib/reallocarray.c compat $CP_LIBC $libc_src/stdlib/reallocarray.c compat
$CP_LIBC $libc_src/stdlib/recallocarray.c compat
$CP_LIBC $libc_src/stdlib/strtonum.c compat $CP_LIBC $libc_src/stdlib/strtonum.c compat
$CP_LIBC $libc_src/crypt/arc4random.c compat $CP_LIBC $libc_src/crypt/arc4random.c compat
$CP_LIBC $libc_src/crypt/arc4random_uniform.c compat $CP_LIBC $libc_src/crypt/arc4random_uniform.c compat


Loading…
Cancel
Save