git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-daemon: fix remote port number in log entry

From
Gerrit Pape <pape@smarden.org>
Date
Nov 5, 2007, 09:16 UTC
Message-ID
<20071105091622.20256.qmail@ae827ecd1d1952.315fe32.mid.smarden.org>

The port number in struct sockaddr_in needs to be converted from network byte order to host byte order (on some architectures).

Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 daemon.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemon.c b/daemon.c
index 660e155..b8df980 100644
--- a/daemon.c
+++ b/daemon.c
@@ -540,7 +540,7 @@ static int execute(struct sockaddr *addr)
 		if (addr->sa_family == AF_INET) {
 			struct sockaddr_in *sin_addr = (void *) addr;
 			inet_ntop(addr->sa_family, &sin_addr->sin_addr, addrbuf, sizeof(addrbuf));
-			port = sin_addr->sin_port;
+			port = ntohs(sin_addr->sin_port);
 #ifndef NO_IPV6
 		} else if (addr && addr->sa_family == AF_INET6) {
 			struct sockaddr_in6 *sin6_addr = (void *) addr;
@@ -550,7 +550,7 @@ static int execute(struct sockaddr *addr)
 			inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(addrbuf) - 1);
 			strcat(buf, "]");
 
-			port = sin6_addr->sin6_port;
+			port = ntohs(sin6_addr->sin6_port);
 #endif
 		}
 		loginfo("Connection from %s:%d", addrbuf, port);
-- 
1.5.3.5
Message 1 of 1 in “git-daemon: fix remote port number in log entry”
  1. git-daemon: fix remote port number in log entryGerrit Pape, Nov 5, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.