Package: netkit-ftp / 0.17-31

050_support_gnu_hurd.diff Patch series | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Description: Support GNU/Hurd
 Add fall-back macro definitions for PATH_MAX,
 MAXPATHLEN, and MAXHOSTNAMELEN, all of which are
 not specified by POSIX, hence are legally missing
 for GNU/Hurd.
 .
 Replace a few uses of these macros by "sizeof()",
 in order to improve robustness of their value.
 Since PATH_MAX and MAXPATHLEN are implicitly
 assumed to be equal.
Author: Mats Erik Andersson <debian@gisladisker.se>
Forwarded: no
Last-Update: 2012-03-28

--- netkit-ftp-0.17.debian/ftp/ftp_var.h
+++ netkit-ftp-0.17/ftp/ftp_var.h
@@ -42,6 +42,24 @@
 #include <sys/param.h>
 
 /*
+ * The following macros are non-POSIX, and are missing
+ * for GNU/Hurd.  They are used statically in the present
+ * source code, so the values have been borrowed from
+ * Glibc as present in GNU/kFreeBSD.
+ */
+#ifndef PATH_MAX
+# define PATH_MAX 1024
+#endif
+
+#ifndef MAXPATHLEN
+# define MAXPATHLEN PATH_MAX
+#endif
+
+#ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 256
+#endif
+
+/*
  * Tick counter step size.
  */
 #define TICKBYTES     10240
--- netkit-ftp-0.17.debian/ftp/cmds.c
+++ netkit-ftp-0.17/ftp/cmds.c
@@ -1041,7 +1041,7 @@
 	for (sp = pattern, nrslash = 0; sp != 0; sp = strchr(sp, '/')) {
 		while (*sp == '/')
 			sp++;
-		if (nrslash >= MAXPATHLEN) {
+		if (nrslash >= sizeof(dotdot)) {
 			printf("Incredible pattern: %s\n", pattern);
 			return 0;
 		}
@@ -2095,11 +2095,11 @@
 		cp = index(altarg, ' ');
 	}
 	*cp = '\0';
-	(void) strncpy(mapin, altarg, PATH_MAX - 1);
-	mapin[PATH_MAX-1] = 0;
+	(void) strncpy(mapin, altarg, sizeof(mapin) - 1);
+	mapin[sizeof(mapin)-1] = 0;
 	while (*++cp == ' ');
-	(void) strncpy(mapout, cp, PATH_MAX - 1);
-	mapout[PATH_MAX-1] = 0;
+	(void) strncpy(mapout, cp, sizeof(mapout) - 1);
+	mapout[sizeof(mapout)-1] = 0;
 }
 
 static