File: 0013-Debian-Build-mantohtml-with-the-build-architecture-c.patch

package info (click to toggle)
cups 2.4.10-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,252 kB
  • sloc: ansic: 159,550; cpp: 8,666; sh: 5,479; makefile: 2,783; php: 17; python: 10
file content (102 lines) | stat: -rw-r--r-- 3,198 bytes parent folder | download | duplicates (2)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From: Helmut Grohne <helmut@subdivi.de>
Date: Tue, 9 Aug 2016 18:11:49 +0200
Subject: Debian: Build mantohtml with the build architecture compiler

mantohtml is run during build. Thus it needs to be built with the build
architecture compiler (or execution fails). The obvious part is switching to
CC_FOR_BUILD. That also depends on it not requiring any other cups components.
In particular, removing uses of strlcpy and replacing host architecture-
specific includes is thus needed.

Bug-Debian: https://bugs.debian.org/837936
Forwarded: not-needed
---
 Makedefs.in     |  1 +
 configure.ac    | 10 ++++++++++
 man/Makefile    |  5 ++---
 man/mantohtml.c | 12 ++++++++----
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/Makedefs.in b/Makedefs.in
index 42c8f23..5d5d4fe 100644
--- a/Makedefs.in
+++ b/Makedefs.in
@@ -23,6 +23,7 @@ CUPS_VERSION    =       @CUPS_VERSION@
 AR		=	@AR@
 AWK		=	@AWK@
 CC		=	@LIBTOOL_CC@ @CC@
+CC_FOR_BUILD	=	@CC_FOR_BUILD@
 CHMOD		=	@CHMOD@
 CXX		=	@LIBTOOL_CXX@ @CXX@
 DSO		=	@DSO@
diff --git a/configure.ac b/configure.ac
index 3b5dd73..d29d876 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,6 +25,16 @@ sinclude(config-scripts/cups-opsys.m4)
 sinclude(config-scripts/cups-common.m4)
 sinclude(config-scripts/cups-directories.m4)
 sinclude(config-scripts/cups-manpages.m4)
+
+AC_MSG_CHECKING([for build system compiler])
+if test "$cross_compiling" = yes; then
+       CC_FOR_BUILD=${CC_FOR_BUILD-cc}
+else
+       CC_FOR_BUILD=${CC}
+fi
+AC_MSG_RESULT(${CC_FOR_BUILD})
+AC_SUBST(CC_FOR_BUILD)
+
 sinclude(config-scripts/cups-sharedlibs.m4)
 sinclude(config-scripts/cups-libtool.m4)
 sinclude(config-scripts/cups-compiler.m4)
diff --git a/man/Makefile b/man/Makefile
index d6e496a..d883fc2 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -223,6 +223,5 @@ html:	$(MAN1) $(MAN5) $(MAN7) $(MAN8) mantohtml
 		./mantohtml $$file >../doc/help/man-`basename $$file .8`.html; \
 	done
 
-mantohtml:	mantohtml.o ../cups/$(LIBCUPSSTATIC)
-	$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ mantohtml.o $(LINKCUPSSTATIC)
-	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+mantohtml:	mantohtml.c
+	$(CC_FOR_BUILD) -o $@ $<
diff --git a/man/mantohtml.c b/man/mantohtml.c
index a46b70e..16ac191 100644
--- a/man/mantohtml.c
+++ b/man/mantohtml.c
@@ -11,8 +11,10 @@
  * Include necessary headers.
  */
 
-#include <cups/string-private.h>
-#include <cups/array-private.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 
@@ -811,7 +813,8 @@ main(int  argc,				/* I - Number of command-line args */
         * Anchor for HTML output...
         */
 
-        strlcpy(anchor, line + 4, sizeof(anchor));
+        strncpy(anchor, line + 4, sizeof(anchor) - 1);
+        anchor[sizeof(anchor) - 1] = '\0';
       }
       else if (strncmp(line, ".\\\"", 3))
       {
@@ -944,7 +947,8 @@ html_alternate(const char *s,		/* I - String */
 		manfile[1024],		// Man page filename
 		manurl[1024];		// Man page URL
 
-        strlcpy(name, s, sizeof(name));
+        strncpy(name, s, sizeof(name) - 1);
+        name[sizeof(name) - 1] = '\0';
         if ((size_t)(end - s) < sizeof(name))
           name[end - s] = '\0';