1From 941038fc05be21202cab7a7a9434097fb55ecbe0 Mon Sep 17 00:00:00 2001
2From: Thorsten Glaser <tg@mirbsd.de>
3Date: Thu, 31 Jul 2014 16:29:41 +0930
4Subject: [PATCH] __progname[] is provided by libc
5
6Rename local variable to tftpd_progname to avoid a clash with glibc
7global symbols and work around Debian bug #519006 (Closes: #564052).
8
9[ hpa: specifically, double-underscore symbols in C are reserved for
10  the implementation, i.e. compiler/libc. ]
11
12Signed-off-by: Ron Lee <ron@debian.org>
13Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
14---
15 tftpd/tftpd.c | 10 +++++-----
16 1 file changed, 5 insertions(+), 5 deletions(-)
17
18diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
19index e247b97..5fec7bf 100644
20--- a/tftpd/tftpd.c
21+++ b/tftpd/tftpd.c
22@@ -76,7 +76,7 @@ static int ai_fam = AF_INET;
23 #define TRIES   6               /* Number of attempts to send each packet */
24 #define TIMEOUT_LIMIT ((1 << TRIES)-1)
25
26-const char *__progname;
27+const char *tftpd_progname;
28 static int peer;
29 static unsigned long timeout  = TIMEOUT;        /* Current timeout value */
30 static unsigned long rexmtval = TIMEOUT;       /* Basic timeout value */
31@@ -395,9 +395,9 @@ int main(int argc, char **argv)
32     /* basename() is way too much of a pain from a portability standpoint */
33
34     p = strrchr(argv[0], '/');
35-    __progname = (p && p[1]) ? p + 1 : argv[0];
36+    tftpd_progname = (p && p[1]) ? p + 1 : argv[0];
37
38-    openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
39+    openlog(tftpd_progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
40
41     srand(time(NULL) ^ getpid());
42
43@@ -946,14 +946,14 @@ int main(int argc, char **argv)
44        syslog daemon gets restarted by the time we get here. */
45     if (secure && standalone) {
46         closelog();
47-        openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
48+        openlog(tftpd_progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
49     }
50
51 #ifdef HAVE_TCPWRAPPERS
52     /* Verify if this was a legal request for us.  This has to be
53        done before the chroot, while /etc is still accessible. */
54     request_init(&wrap_request,
55-                 RQ_DAEMON, __progname,
56+                 RQ_DAEMON, tftpd_progname,
57                  RQ_FILE, fd,
58                  RQ_CLIENT_SIN, &from, RQ_SERVER_SIN, &myaddr, 0);
59     sock_methods(&wrap_request);
60--
612.14.1
62
63