diff options
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r-- | sysdeps/mach/hurd/getpeername.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sysdeps/mach/hurd/getpeername.c b/sysdeps/mach/hurd/getpeername.c index 39071c1da4..325b6fd75d 100644 --- a/sysdeps/mach/hurd/getpeername.c +++ b/sysdeps/mach/hurd/getpeername.c @@ -55,11 +55,14 @@ __getpeername (int fd, __SOCKADDR_ARG addrarg, socklen_t *len) } const sa_family_t family = type; - if (*len < (char *) (&addr->sa_family + 1) - (char *) addr) - memcpy (&addr->sa_family, &family, - *len - offsetof (struct sockaddr, sa_family)); - else - addr->sa_family = family; + if (*len > offsetof (struct sockaddr, sa_family)) + { + if (*len < (char *) (&addr->sa_family + 1) - (char *) addr) + memcpy (&addr->sa_family, &family, + *len - offsetof (struct sockaddr, sa_family)); + else + addr->sa_family = family; + } return 0; } |