Add strnlen() replacement needed for glob.c.
Only used if no glob() and no strnlen().
This commit is contained in:
1
MANIFEST
1
MANIFEST
@@ -159,6 +159,7 @@ lib/util/siglist.in
|
|||||||
lib/util/snprintf.c
|
lib/util/snprintf.c
|
||||||
lib/util/strlcat.c
|
lib/util/strlcat.c
|
||||||
lib/util/strlcpy.c
|
lib/util/strlcpy.c
|
||||||
|
lib/util/strnlen.c
|
||||||
lib/util/strsignal.c
|
lib/util/strsignal.c
|
||||||
lib/util/strtobool.c
|
lib/util/strtobool.c
|
||||||
lib/util/strtoid.c
|
lib/util/strtoid.c
|
||||||
|
@@ -662,6 +662,9 @@
|
|||||||
/* Define to 1 if you have the `strlcpy' function. */
|
/* Define to 1 if you have the `strlcpy' function. */
|
||||||
#undef HAVE_STRLCPY
|
#undef HAVE_STRLCPY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strnlen' function. */
|
||||||
|
#undef HAVE_STRNLEN
|
||||||
|
|
||||||
/* Define to 1 if you have the `strsignal' function. */
|
/* Define to 1 if you have the `strsignal' function. */
|
||||||
#undef HAVE_STRSIGNAL
|
#undef HAVE_STRSIGNAL
|
||||||
|
|
||||||
|
26
configure
vendored
26
configure
vendored
@@ -18930,6 +18930,32 @@ esac
|
|||||||
"
|
"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for ac_func in strnlen
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen"
|
||||||
|
if test "x$ac_cv_func_strnlen" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_STRNLEN 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
case " $LIBOBJS " in
|
||||||
|
*" strnlen.$ac_objext "* ) ;;
|
||||||
|
*) LIBOBJS="$LIBOBJS strnlen.$ac_objext"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
for _sym in sudo_strnlen; do
|
||||||
|
COMPAT_EXP="${COMPAT_EXP}${_sym}
|
||||||
|
"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@@ -2574,6 +2574,10 @@ SUDO_FUNC_ISBLANK
|
|||||||
AC_CHECK_FUNCS([glob], [], [
|
AC_CHECK_FUNCS([glob], [], [
|
||||||
AC_LIBOBJ(glob)
|
AC_LIBOBJ(glob)
|
||||||
SUDO_APPEND_COMPAT_EXP(sudo_glob sudo_globfree)
|
SUDO_APPEND_COMPAT_EXP(sudo_glob sudo_globfree)
|
||||||
|
AC_CHECK_FUNCS([strnlen], [], [
|
||||||
|
AC_LIBOBJ(strnlen)
|
||||||
|
SUDO_APPEND_COMPAT_EXP(sudo_strnlen)
|
||||||
|
])
|
||||||
])
|
])
|
||||||
AC_CHECK_FUNCS([memrchr], [], [
|
AC_CHECK_FUNCS([memrchr], [], [
|
||||||
AC_LIBOBJ(memrchr)
|
AC_LIBOBJ(memrchr)
|
||||||
|
@@ -431,6 +431,11 @@ __dso_public size_t sudo_strlcpy(char *dst, const char *src, size_t siz);
|
|||||||
# undef strlcpy
|
# undef strlcpy
|
||||||
# define strlcpy(_a, _b, _c) sudo_strlcpy((_a), (_b), (_c))
|
# define strlcpy(_a, _b, _c) sudo_strlcpy((_a), (_b), (_c))
|
||||||
#endif /* HAVE_STRLCPY */
|
#endif /* HAVE_STRLCPY */
|
||||||
|
#if !defined(HAVE_GLOB) && !defined(HAVE_STRNLEN)
|
||||||
|
__dso_public size_t sudo_strnlen(char *str, size_t maxlen);
|
||||||
|
# undef strnlen
|
||||||
|
# define strnlen(_a, _b) sudo_strnlen((_a), (_b))
|
||||||
|
#endif /* !HAVE_GLOB && !HAVE_STRNLEN */
|
||||||
#ifndef HAVE_MEMRCHR
|
#ifndef HAVE_MEMRCHR
|
||||||
__dso_public void *sudo_memrchr(const void *s, int c, size_t n);
|
__dso_public void *sudo_memrchr(const void *s, int c, size_t n);
|
||||||
# undef memrchr
|
# undef memrchr
|
||||||
|
36
lib/util/strnlen.c
Normal file
36
lib/util/strnlen.c
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/* $OpenBSD: strnlen.c,v 1.5 2014/06/10 04:17:37 deraadt Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* 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 <config.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_STRNLEN
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
size_t
|
||||||
|
strnlen(const char *str, size_t maxlen)
|
||||||
|
{
|
||||||
|
const char *cp;
|
||||||
|
|
||||||
|
for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--)
|
||||||
|
;
|
||||||
|
|
||||||
|
return (size_t)(cp - str);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_STRNLEN */
|
Reference in New Issue
Block a user