Mailing List Archive

svn commit: r1900986 - in /httpd/httpd/branches/2.4.x: ./ modules/cluster/mod_heartmonitor.c
Author: icing
Date: Tue May 17 13:32:43 2022
New Revision: 1900986

URL: http://svn.apache.org/viewvc?rev=1900986&view=rev
Log:
Merge /httpd/httpd/trunk:r1899841

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*.


Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/modules/cluster/mod_heartmonitor.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1899841

Modified: httpd/httpd/branches/2.4.x/modules/cluster/mod_heartmonitor.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/cluster/mod_heartmonitor.c?rev=1900986&r1=1900985&r2=1900986&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/cluster/mod_heartmonitor.c (original)
+++ httpd/httpd/branches/2.4.x/modules/cluster/mod_heartmonitor.c Tue May 17 13:32:43 2022
@@ -171,7 +171,7 @@ static apr_status_t hm_update(void* mem,
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,
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_
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;