add compatibility implementation for strnlen
fixes https://github.com/OpenSC/OpenSC/issues/660
This commit is contained in:
parent
a0c0087446
commit
89f9d9e85d
|
@ -335,7 +335,7 @@ AC_FUNC_VPRINTF
|
|||
AC_CHECK_FUNCS([ \
|
||||
getpass gettimeofday memset mkdir \
|
||||
strdup strerror getopt_long getopt_long_only \
|
||||
strlcpy strlcat
|
||||
strlcpy strlcat strnlen
|
||||
])
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
if test "${ac_cv_sizeof_void_p}" = 8; then
|
||||
|
|
|
@ -15,6 +15,7 @@ libcompat_la_SOURCES = \
|
|||
compat_dummy.c \
|
||||
compat_strlcat.h compat_strlcat.c \
|
||||
compat_strlcpy.h compat_strlcpy.c \
|
||||
compat_strnlen.h compat_strnlen.c \
|
||||
compat_getpass.h compat_getpass.c \
|
||||
compat_getopt.h compat_getopt.c \
|
||||
compat_report_rangecheckfailure.c \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
TOPDIR = ..\..
|
||||
|
||||
COMMON_OBJECTS = compat_getpass.obj compat_getopt.obj compat_strlcpy.obj compat_strlcat.obj simclist.obj compat_report_rangecheckfailure.obj
|
||||
COMMON_OBJECTS = compat_getpass.obj compat_getopt.obj compat_strlcpy.obj compat_strlcat.obj compat_strnlen.obj simclist.obj compat_report_rangecheckfailure.obj
|
||||
|
||||
all: common.lib libpkcs11.lib libscdl.lib
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* $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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <string.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
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* @file
|
||||
* @brief prototype of strnlen() from OpenBSD
|
||||
*/
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t strnlen(const char *str, size_t maxlen)
|
||||
#endif
|
|
@ -35,6 +35,7 @@
|
|||
#include "internal.h"
|
||||
#include "asn1.h"
|
||||
#include "pkcs15.h"
|
||||
#include "common/compat_strnlen.h"
|
||||
|
||||
|
||||
int
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "pkcs15.h"
|
||||
#include "asn1.h"
|
||||
#include "common/compat_strlcpy.h"
|
||||
#include "common/compat_strnlen.h"
|
||||
|
||||
#include "card-sc-hsm.h"
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libopensc/log.h"
|
||||
#include "libopensc/asn1.h"
|
||||
#include "libopensc/cardctl.h"
|
||||
#include "common/compat_strnlen.h"
|
||||
|
||||
#ifdef ENABLE_OPENSSL
|
||||
#include <openssl/opensslv.h>
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
#define S_IWUSR S_IWRITE
|
||||
#endif
|
||||
|
||||
#define HAVE_STRNLEN
|
||||
#define HAVE_IO_H
|
||||
#define ENABLE_PCSC
|
||||
#define HAVE_WINSCARD_H
|
||||
|
|
Loading…
Reference in New Issue