From ea54a05fc311f6a42bf25f552fe106b694f675df Mon Sep 17 00:00:00 2001 From: "roberto@silente" Date: Tue, 8 Jun 2010 07:43:48 +0200 Subject: [PATCH] OpenBSD fixes by Piotr Sikora --- plugins.c | 8 ++++---- sendfile.c | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins.c b/plugins.c index 15eddd86..963e1a36 100644 --- a/plugins.c +++ b/plugins.c @@ -30,7 +30,7 @@ int uwsgi_load_plugin(struct uwsgi_server *uwsgi, int modifier, char *plugin, ch if (absolute) { plugin_name = malloc(strlen(plugin) + 1); - strcpy(plugin_name, plugin); + strlcpy(plugin_name, plugin, strlen(plugin)); } else { plugin_name = malloc(strlen(UWSGI_PLUGIN_DIR) + 1 + strlen(plugin) + 1); @@ -38,9 +38,9 @@ int uwsgi_load_plugin(struct uwsgi_server *uwsgi, int modifier, char *plugin, ch uwsgi_error("malloc()"); return -1 ; } - strcpy(plugin_name, UWSGI_PLUGIN_DIR); - strcat(plugin_name, "/"); - strcat(plugin_name, plugin); + strlcpy(plugin_name, UWSGI_PLUGIN_DIR, strlen(UWSGI_PLUGIN_DIR)); + strlcat(plugin_name, "/", 1); + strlcat(plugin_name, plugin, strlen(plugin)); } plugin_handle = dlopen(plugin_name, RTLD_NOW | RTLD_GLOBAL); free(plugin_name); diff --git a/sendfile.c b/sendfile.c index 61f146de..ea8a6c20 100644 --- a/sendfile.c +++ b/sendfile.c @@ -59,10 +59,11 @@ ssize_t uwsgi_sendfile(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk, off_t *pos, int async) { - int sf_ret; #if defined(__FreeBSD__) || defined(__DragonFly__) + int sf_ret; + off_t sf_len = filesize ; if (async > 1) { @@ -81,6 +82,7 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk, return sf_len; #elif defined(__APPLE__) + int sf_ret; off_t sf_len = filesize ; if (async > 1) { @@ -100,6 +102,8 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk, return sf_len; #elif defined(__linux__) || defined(__sun__) + int sf_ret; + if (async > 1) { sf_ret = sendfile(sockfd, filefd, pos, chunk); } @@ -114,7 +118,7 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk, return sf_ret ; #else - static nosf_buf_size = 0 ; + static size_t nosf_buf_size = 0 ; static char *nosf_buf ; ssize_t jlen = 0;