]> git.proxmox.com Git - mirror_corosync.git/commitdiff
totemconfig: Replace strcpy by strncpy
authorJan Friesse <jfriesse@redhat.com>
Tue, 16 Oct 2018 08:28:56 +0000 (10:28 +0200)
committerJan Friesse <jfriesse@redhat.com>
Tue, 16 Oct 2018 10:30:58 +0000 (12:30 +0200)
Formally not needed, because totemip_print should not return string
longer than INET6_ADDRSTRLEN, but static analysis tools are not capable
of such conclusion.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
exec/totemconfig.c

index e274b35ce53f1dae2fc4b46146d24e98a22bd796..a92978d2793a7a65d602f73aaa95729951e9f098 100644 (file)
@@ -1143,7 +1143,8 @@ static void check_things_have_not_changed(struct totem_config *totem_config)
                                           sizeof(struct totem_ip_address))) {
 
                                        ip_str = totemip_print(&totem_config->orig_interfaces[i].member_list[j]);
-                                       strcpy(addr_buf, ip_str);
+                                       strncpy(addr_buf, ip_str, sizeof(addr_buf));
+                                       addr_buf[sizeof(addr_buf) - 1] = '\0';
                                        log_printf(LOGSYS_LEVEL_ERROR, "new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n", i, addr_buf, totemip_print(&totem_config->interfaces[i].member_list[j]));
                                        changed = 1;
                                }