]> git.proxmox.com Git - mirror_corosync.git/commitdiff
totemconfig: fix integer underflow and logic bug v3.1.1
authorJohannes Krupp <johannes.krupp@cispa.saarland>
Mon, 29 Mar 2021 09:00:25 +0000 (11:00 +0200)
committerJan Friesse <jfriesse@redhat.com>
Mon, 29 Mar 2021 12:05:04 +0000 (14:05 +0200)
Fix integer underflow when computing `namelen` in `nodelist_byname`,
always use computed `namelen`.
Fixes #626.

Signed-off-by: Johannes Krupp <johannes.krupp@cispa.saarland>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
exec/totemconfig.c

index b8856073a82e02ef002e1ca5b50c8e43426e4746..645ff9ef89a4a6b6260addf9081993d9a1a09aec 100644 (file)
@@ -651,11 +651,11 @@ static int nodelist_byname(icmap_map_t map, const char *find_name, int strip_dom
                        char *dot;
                        dot = strchr(name, '.');
                        if (dot) {
-                               namelen = name - dot - 1;
+                               namelen = dot - name;
                        }
                }
                if (strncmp(find_name, name, namelen) == 0 &&
-                   strlen(find_name) == strlen(name)) {
+                   strlen(find_name) == namelen) {
                        icmap_iter_finalize(iter);
                        return node_pos;
                }