summaryrefslogtreecommitdiff
path: root/network/redir/patches/02_use_ntohs.dpatch
blob: 58622b0ddf89a3dcf864f9a34ab7058e5168b8bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_use_ntohs.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: use ntohs() to generate comprehensible debug()s and syslog()s.

@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c	1999-12-26 15:50:06.000000000 -0500
+++ redir-2.2.1/redir.c	2005-10-22 21:29:55.491735272 -0400
@@ -745,7 +745,7 @@
 	}
      
 	debug1("peer IP is %s\n", inet_ntoa(client.sin_addr));
-	debug1("peer socket is %d\n", client.sin_port);
+	debug1("peer socket is %d\n", ntohs(client.sin_port));
 
 	/*
 	 * Double fork here so we don't have to wait later
@@ -871,8 +871,8 @@
 		strcpy(tmp2, inet_ntoa(target->sin_addr));
 	  
 		syslog(LOG_NOTICE, "connecting %s/%d to %s/%d",
-		       tmp1, client.sin_port,
-		       tmp2, target->sin_port);
+		       tmp1, ntohs(client.sin_port),
+		       tmp2, ntohs(target->sin_port));
 	}
 
 	/* do proxy stuff */
@@ -1066,7 +1066,7 @@
 
 		if (!getpeername(0, (struct sockaddr *) &client, &client_size)) {
 			debug1("peer IP is %s\n", inet_ntoa(client.sin_addr));
-			debug1("peer socket is %d\n", client.sin_port);
+			debug1("peer socket is %d\n", ntohs(client.sin_port));
 		}
 		if ((targetsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 			perror("target: socket");
@@ -1109,8 +1109,8 @@
 
 		if (dosyslog) {
 			syslog(LOG_NOTICE, "connecting %s/%d to %s/%d",
-			       inet_ntoa(client.sin_addr), client.sin_port,
-			       target_ip, target.sin_port);
+			       inet_ntoa(client.sin_addr), ntohs(client.sin_port),
+			       target_ip, ntohs(target.sin_port));
 		}
 
 		/* Just start copying - one side of the loop is stdin - 0 */