File: fix_mdns_use.dpatch

package info (click to toggle)
simpleproxy 3.5-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch, trixie
  • size: 276 kB
  • ctags: 88
  • sloc: ansic: 1,417; sh: 214; makefile: 35
file content (46 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (4)
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
#! /bin/sh /usr/share/dpatch/dpatch-run
## fix_mdns_use.dpatch by  <apollock@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Switches from gethostbyaddr() to getnameinfo() to fix performance 
## DP: issues when using nss_mdns
## DP: See http://bugs.debian.org/508148

@DPATCH@
diff -urNad simpleproxy-3.4~/simpleproxy.c simpleproxy-3.4/simpleproxy.c
--- simpleproxy-3.4~/simpleproxy.c	2005-08-25 21:45:46.000000000 -0700
+++ simpleproxy-3.4/simpleproxy.c	2008-12-08 23:30:27.000000000 -0800
@@ -78,6 +78,9 @@
 #include <arpa/inet.h>
 #include <ctype.h>
 
+#include <sys/socket.h>
+#include <netdb.h>
+
 #include "cfg.h"
 
 #ifndef nil
@@ -166,6 +169,9 @@
     int    rsp = 1;
     char  *http_auth = nil;
     char  *HTTPAuthHash = nil;
+    struct sockaddr *sa;
+    int    len;
+    char   hbuf[NI_MAXHOST];
 
     /* Check for the arguments, and overwrite values from cfg file */
     while((c = getopt(ac, av, "iVv7dhL:R:H:f:p:P:D:S:s:a:t:")) != -1)
@@ -394,8 +400,11 @@
                 break;
                 
             case 0: /* Child */
-                hp = gethostbyaddr((char *)&cli_addr, clien, AF_INET);
-                client_name = strdup(hp?(hp->h_name): inet_ntoa(cli_addr.sin_addr));
+		if (getnameinfo((const struct sockaddr *) &cli_addr, len,
+					hbuf, sizeof(hbuf), NULL, 0, 0) == 0)
+			client_name = strdup(hbuf);
+		else
+			client_name = inet_ntoa(cli_addr.sin_addr);
 
                 /*
                  * I don't know is that a bug, but on Irix 6.2 parent