Skip to content

Commit c67359b

Browse files
g-papegitster
authored andcommitted
git-daemon: fix remote port number in log entry
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb15958 commit c67359b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

daemon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static int execute(struct sockaddr *addr)
540540
if (addr->sa_family == AF_INET) {
541541
struct sockaddr_in *sin_addr = (void *) addr;
542542
inet_ntop(addr->sa_family, &sin_addr->sin_addr, addrbuf, sizeof(addrbuf));
543-
port = sin_addr->sin_port;
543+
port = ntohs(sin_addr->sin_port);
544544
#ifndef NO_IPV6
545545
} else if (addr && addr->sa_family == AF_INET6) {
546546
struct sockaddr_in6 *sin6_addr = (void *) addr;
@@ -550,7 +550,7 @@ static int execute(struct sockaddr *addr)
550550
inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(addrbuf) - 1);
551551
strcat(buf, "]");
552552

553-
port = sin6_addr->sin6_port;
553+
port = ntohs(sin6_addr->sin6_port);
554554
#endif
555555
}
556556
loginfo("Connection from %s:%d", addrbuf, port);

0 commit comments

Comments
 (0)