mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:45:07 -05:00
socket: zero sockaddr_un to initialize sa_len
Zero the whole sockaddr struct before calling bind() and connect() to initialize the FreeBSD-specific sa_len field. This fixes errors reported by valgrind.
This commit is contained in:
4
socket.c
4
socket.c
@@ -505,6 +505,8 @@ bind_unix_address(int sock_fd, const char *addr, int flags)
|
|||||||
{
|
{
|
||||||
union sockaddr_all saddr;
|
union sockaddr_all saddr;
|
||||||
|
|
||||||
|
memset(&saddr, 0, sizeof (saddr));
|
||||||
|
|
||||||
if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >=
|
if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >=
|
||||||
sizeof (saddr.un.sun_path)) {
|
sizeof (saddr.un.sun_path)) {
|
||||||
DEBUG_LOG("Unix socket path %s too long", addr);
|
DEBUG_LOG("Unix socket path %s too long", addr);
|
||||||
@@ -537,6 +539,8 @@ connect_unix_address(int sock_fd, const char *addr)
|
|||||||
{
|
{
|
||||||
union sockaddr_all saddr;
|
union sockaddr_all saddr;
|
||||||
|
|
||||||
|
memset(&saddr, 0, sizeof (saddr));
|
||||||
|
|
||||||
if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >=
|
if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >=
|
||||||
sizeof (saddr.un.sun_path)) {
|
sizeof (saddr.un.sun_path)) {
|
||||||
DEBUG_LOG("Unix socket path %s too long", addr);
|
DEBUG_LOG("Unix socket path %s too long", addr);
|
||||||
|
|||||||
Reference in New Issue
Block a user