From 039e9dc5e609f32b959b6120976e2c59534c659f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Aug 2003 20:19:30 +0000 Subject: - patch to fix a memory leak from metze - fix a couple of unicode string errors for ascii clients found by RAW- tests (This used to be commit 81c941ba8ae33567d79b4bb0bb5928f5f6077b76) --- source4/lib/util_sock.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'source4/lib') 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)); } -- cgit