From ca1d5d7af2e9ebc0a367a16d5a5069ce4a64f14e Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Fri, 6 Jan 2012 16:51:55 +0000 Subject: [PATCH] Cure size_t abuse; Backport r1227856 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1228262 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_protocol.h | 6 ++++-- modules/proxy/ajp_msg.c | 2 +- modules/proxy/mod_proxy.h | 3 ++- modules/proxy/proxy_util.c | 10 ++++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/http_protocol.h b/include/http_protocol.h index 77493de586..377b8f1248 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -209,8 +209,10 @@ AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t of * @param length The amount of data to send * @return The number of bytes sent */ -AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, - size_t length); +AP_DECLARE(apr_size_t) ap_send_mmap(apr_mmap_t *mm, + request_rec *r, + apr_size_t offset, + apr_size_t length); #endif diff --git a/modules/proxy/ajp_msg.c b/modules/proxy/ajp_msg.c index 69e232a394..638dfee2d8 100644 --- a/modules/proxy/ajp_msg.c +++ b/modules/proxy/ajp_msg.c @@ -326,7 +326,7 @@ apr_status_t ajp_msg_append_uint8(ajp_msg_t *msg, apr_byte_t value) apr_status_t ajp_msg_append_string_ex(ajp_msg_t *msg, const char *value, int convert) { - size_t len; + apr_size_t len; if (value == NULL) { return(ajp_msg_append_uint16(msg, 0xFFFF)); diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 3cc5ed83d7..285de4222c 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -522,7 +522,8 @@ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status, /* proxy_util.c */ -PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src, size_t dlen); +PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src, + apr_size_t dlen); PROXY_DECLARE(int) ap_proxy_hex2c(const char *x); PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x); PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t, diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index e975af94bc..2fa2d7e2f1 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -78,13 +78,15 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr), (r, pr), OK, DECLINED) -PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src, size_t dlen) +PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src, + apr_size_t dlen) { if ((strlen(src)+1) > dlen) { - /* APR_ENOSPACE would be better */ + /* XXX: APR_ENOSPACE would be better */ return APR_EGENERAL; } else { + /* XXX: Once slen and dlen are known, no excuse not to memcpy */ apr_cpystrn(dst, src, dlen); } return APR_SUCCESS; @@ -921,14 +923,14 @@ PROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_req_conf *rconf = ap_get_module_config(r->request_config, &proxy_module); struct proxy_alias *ent; - size_t len = strlen(str); + apr_size_t len = strlen(str); const char *newpath = NULL; const char *newdomain = NULL; const char *pathp; const char *domainp; const char *pathe = NULL; const char *domaine = NULL; - size_t l1, l2, poffs = 0, doffs = 0; + apr_size_t l1, l2, poffs = 0, doffs = 0; int i; int ddiff = 0; int pdiff = 0; -- 2.40.0