Mercurial > hg > freeDiameter
diff extensions/app_radgw/rgw_clients.c @ 1442:915450ee91c7
fix gcc 9.1.1 compile warnings
Use snprintf instead of strncpy to ensure NUL termination.
Simplify attribute copying to calloc/memcpy instead
of malloc/memset/strncpy/assignment.
Appeases gcc 9.1.1 warnings about strncpy bounds.
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Thu, 27 Feb 2020 16:19:24 +1100 |
parents | 0918e88f7c33 |
children | 566bb46cc73f |
line wrap: on
line diff
--- a/extensions/app_radgw/rgw_clients.c Tue Feb 25 10:42:08 2020 +1100 +++ b/extensions/app_radgw/rgw_clients.c Thu Feb 27 16:19:24 2020 +1100 @@ -763,7 +763,7 @@ hint.ai_flags = AI_CANONNAME; ret = getaddrinfo(buf, NULL, &hint, &res); if (ret == 0) { - strncpy(buf, res->ai_canonname, sizeof(buf)); + snprintf(buf, sizeof(buf), "%s", res->ai_canonname); /* The name was resolved correctly, does it match the IP of the client? */ for (ptr = res; ptr != NULL; ptr = ptr->ai_next) { if (cli->sa->sa_family != ptr->ai_family)