diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | http.c | 1 | ||||
-rw-r--r-- | strlcpy-internal.h | 23 | ||||
-rw-r--r-- | strlcpy.c | 6 | ||||
-rw-r--r-- | test/regress_http.c | 4 |
6 files changed, 33 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am index 92bb97d8..ab590b18 100644 --- a/Makefile.am +++ b/Makefile.am @@ -40,8 +40,8 @@ SYS_INCLUDES = endif libevent_la_SOURCES = event.c buffer.c evbuffer.c log.c event_tagging.c \ - http.c evhttp.h http-internal.h evdns.c evdns.h evrpc.c \ - evrpc.h evrpc-internal.h $(SYS_SRC) + http.c evhttp.h http-internal.h evdns.c evdns.h evrpc.c strlcpy.c \ + evrpc.h evrpc-internal.h strlcpy-internal.h $(SYS_SRC) libevent_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS) libevent_la_LDFLAGS = -release @VERSION@ -version-info 1:3:0 diff --git a/configure.in b/configure.in index ddcde2fb..947f5e74 100644 --- a/configure.in +++ b/configure.in @@ -132,8 +132,7 @@ AC_C_INLINE AC_HEADER_TIME dnl Checks for library functions. -AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo) -AC_REPLACE_FUNCS(strlcpy) +AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy) if test "x$ac_cv_func_clock_gettime" = "xyes"; then AC_DEFINE(DNS_USE_CPU_CLOCK_FOR_ID, 1, [Define if clock_gettime is available in libc]) @@ -73,6 +73,7 @@ #undef timeout_pending #undef timeout_initialized +#include "strlcpy-internal.h" #include "event.h" #include "evhttp.h" #include "log.h" diff --git a/strlcpy-internal.h b/strlcpy-internal.h new file mode 100644 index 00000000..22b5f61d --- /dev/null +++ b/strlcpy-internal.h @@ -0,0 +1,23 @@ +#ifndef _STRLCPY_INTERNAL_H_ +#define _STRLCPY_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#ifndef HAVE_STRLCPY +#include <string.h> +size_t _event_strlcpy(char *dst, const char *src, size_t siz); +#define strlcpy _event_strlcpy +#endif + +#ifdef __cplusplus +} +#endif + +#endif + @@ -37,7 +37,8 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp #include "config.h" #endif /* HAVE_CONFIG_H */ -#include <string.h> +#ifndef HAVE_STRLCPY +#include "strlcpy-internal.h" /* * Copy src to string dst of size siz. At most siz-1 characters @@ -45,7 +46,7 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t -strlcpy(dst, src, siz) +_event_strlcpy(dst, src, siz) char *dst; const char *src; size_t siz; @@ -72,3 +73,4 @@ strlcpy(dst, src, siz) return(s - src - 1); /* count does not include NUL */ } +#endif diff --git a/test/regress_http.c b/test/regress_http.c index c651bda5..42f6b7e5 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -128,7 +128,7 @@ http_readcb(struct bufferevent *bev, void *arg) event_debug(("%s: %s\n", __func__, EVBUFFER_DATA(bev->input))); - if (evbuffer_find(bev->input, what, strlen(what)) != NULL) { + if (evbuffer_find(bev->input, (const unsigned char*) what, strlen(what)) != NULL) { struct evhttp_request *req = evhttp_request_new(NULL, NULL); req->kind = EVHTTP_RESPONSE; int done = evhttp_parse_lines(req, bev->input); @@ -445,7 +445,7 @@ void http_failure_readcb(struct bufferevent *bev, void *arg) { const char *what = "400 Bad Request"; - if (evbuffer_find(bev->input, what, strlen(what)) != NULL) { + if (evbuffer_find(bev->input, (const unsigned char*) what, strlen(what)) != NULL) { test_ok = 2; bufferevent_disable(bev, EV_READ); event_loopexit(NULL); |