From: Yann Ylavic Date: Thu, 14 Apr 2022 09:44:35 +0000 (+0000) Subject: mod_heartmonitor: Fix setting and comparison of IPs fields. X-Git-Tag: 2.5.0-alpha2-ci-test-only~398 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56ee493d197eb33264dd98ef24e0e2503c4ce2f8;p=thirdparty%2Fapache%2Fhttpd.git mod_heartmonitor: Fix setting and comparison of IPs fields. Setting or comparing hm_server_t and hm_slot_server_t IPs should not be base on MAXIPSIZE since the former is potentially a smaller const char*. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899841 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cluster/mod_heartmonitor.c b/modules/cluster/mod_heartmonitor.c index bfda7f883e2..30db11ac7b8 100644 --- a/modules/cluster/mod_heartmonitor.c +++ b/modules/cluster/mod_heartmonitor.c @@ -171,7 +171,7 @@ static apr_status_t hm_update(void* mem, void *data, apr_pool_t *p) hm_slot_server_t *old = (hm_slot_server_t *) mem; hm_slot_server_ctx_t *s = (hm_slot_server_ctx_t *) data; hm_server_t *new = s->s; - if (strncmp(old->ip, new->ip, MAXIPSIZE)==0) { + if (strcmp(old->ip, new->ip)==0) { s->found = 1; old->busy = new->busy; old->ready = new->ready; @@ -185,7 +185,7 @@ static apr_status_t hm_readid(void* mem, void *data, apr_pool_t *p) hm_slot_server_t *old = (hm_slot_server_t *) mem; hm_slot_server_ctx_t *s = (hm_slot_server_ctx_t *) data; hm_server_t *new = s->s; - if (strncmp(old->ip, new->ip, MAXIPSIZE)==0) { + if (strcmp(old->ip, new->ip)==0) { s->found = 1; s->item_id = old->id; } @@ -202,7 +202,8 @@ static apr_status_t hm_slotmem_update_stat(hm_server_t *s, apr_pool_t *pool) if (!ctx.found) { unsigned int i; hm_slot_server_t hmserver; - memcpy(hmserver.ip, s->ip, MAXIPSIZE); + memset(&hmserver, 0, sizeof(hmserver)); + apr_cpystrn(hmserver.ip, s->ip, sizeof(hmserver.ip)); hmserver.busy = s->busy; hmserver.ready = s->ready; hmserver.seen = s->seen;