summaryrefslogtreecommitdiff
path: root/geography/gpsd/patches/patch-ac
blob: 2bb560e7bc6d5482b3a0a87888344c1ea7e6904c (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
$NetBSD: patch-ac,v 1.3 2008/10/24 13:25:50 gdt Exp $

Don't expose position via INADDR_ANY by default.  Security fix for
http://developer.berlios.de/bugs/?func=detailbug&bug_id=14707&group_id=2116

--- gpsd.c.orig	2008-01-28 15:04:33.000000000 -0500
+++ gpsd.c
@@ -86,6 +86,7 @@
 static fd_set all_fds;
 static int maxfd;
 static int debuglevel;
+static bool listen_global = false;
 static bool in_background = false;
 static bool nowait = false;
 static jmp_buf restartbuf;
@@ -230,7 +231,10 @@ static int passivesock(char *service, ch
     /*@ -mustfreefresh @*/
     memset((char *) &sin, 0, sizeof(sin));
     /*@i1@*/sin.sin_family = AF_INET;
-    sin.sin_addr.s_addr = INADDR_ANY;
+    if (listen_global)
+      sin.sin_addr.s_addr = htonl(INADDR_ANY);
+    else
+      sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
     if ((pse = getservbyname(service, protocol)))
 	sin.sin_port = htons(ntohs((in_port_t)pse->s_port));
@@ -1271,7 +1275,7 @@ int main(int argc, char *argv[])
     (void)setlocale(LC_NUMERIC, "C");
 #endif
     debuglevel = 0;
-    while ((option = getopt(argc, argv, "F:D:S:bhNnP:V"
+    while ((option = getopt(argc, argv, "F:D:S:bhNnP:VG"
 #ifdef RTCM104_SERVICE
 			    "R:"
 #endif /* RTCM104_SERVICE */
@@ -1280,6 +1284,8 @@ int main(int argc, char *argv[])
 	case 'D':
 	    debuglevel = (int) strtol(optarg, 0, 0);
 	    break;
+	case 'G':
+	    listen_global = true;
 	case 'F':
 	    control_socket = optarg;
 	    break;