Skip to content

Commit 9f40f3e

Browse files
author
Tor Didriksen
committed
Bug#38021787 Compile warning in gcs_xcom_networking.cc -Werror=attribute-warning
gcc 14 on EL9, RelWithDebInfo mode said: error: call to '*__inet_ntop_chk' declared with attribute warning: inet_ntop called with bigger length than size of destination buffer [-Werror=attribute-warning] inet_ntop was called with incorrect 'size' argument. Change-Id: I28410550394e2cd0d18ec30832a93af57496f422
1 parent 15939ac commit 9f40f3e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_networking.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,25 +422,26 @@ static bool sock_descriptor_to_sockaddr(int fd, struct sockaddr_storage *sa) {
422422
*/
423423
static bool sock_descriptor_to_string(int fd, std::string &out) {
424424
struct sockaddr_storage sa;
425-
auto addr_size = static_cast<socklen_t>(sizeof(struct sockaddr_storage));
426425
char saddr[INET6_ADDRSTRLEN];
427426

428427
// get the sockaddr struct
429428
sock_descriptor_to_sockaddr(fd, &sa);
430429

431430
// try IPv4
432431
if (sa.ss_family == AF_INET) {
433-
if (inet_ntop(AF_INET, &(((struct sockaddr_in *)&sa)->sin_addr), saddr,
434-
addr_size)) {
432+
auto inaddr = &(((struct sockaddr_in *)&sa)->sin_addr);
433+
if (inet_ntop(AF_INET, inaddr, saddr,
434+
static_cast<socklen_t>(sizeof(saddr)))) {
435435
out = saddr;
436436
return false;
437437
}
438438
}
439439

440440
// try IPv6
441441
if (sa.ss_family == AF_INET6) {
442-
if (inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)&sa)->sin6_addr), saddr,
443-
addr_size)) {
442+
auto inaddr = &(((struct sockaddr_in6 *)&sa)->sin6_addr);
443+
if (inet_ntop(AF_INET6, inaddr, saddr,
444+
static_cast<socklen_t>(sizeof(saddr)))) {
444445
out = saddr;
445446
return false;
446447
}

0 commit comments

Comments
 (0)