summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/util_sock.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c
index 8362290804..95e0c5fe0c 100644
--- a/source4/lib/util_sock.c
+++ b/source4/lib/util_sock.c
@@ -486,22 +486,12 @@ char *get_socket_addr(TALLOC_CTX *mem_ctx, int fd)
struct sockaddr sa;
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
- char *addr_buf;
- addr_buf = talloc_strdup(mem_ctx, "0.0.0.0");
-
- if (fd == -1) {
- return addr_buf;
- }
-
- if (getpeername(fd, &sa, &length) < 0) {
- DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
- return addr_buf;
+ if (fd == -1 || getpeername(fd, &sa, &length) == -1) {
+ return talloc_strdup(mem_ctx, "0.0.0.0");
}
- addr_buf = talloc_strdup(mem_ctx, (char *)inet_ntoa(sockin->sin_addr));
-
- return addr_buf;
+ return talloc_strdup(mem_ctx, (char *)inet_ntoa(sockin->sin_addr));
}