summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-04-24 10:25:25 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-04-26 10:05:13 +0100
commit8f0517a6b30470d9ad51d3a5263cbc372ad0e27e (patch)
tree436995dfb68600e736ad7239d31975371c9c19db /meta
parent2b05d3545594cb80289f0850b85184bd2422f806 (diff)
downloadpoky-8f0517a6b30470d9ad51d3a5263cbc372ad0e27e.tar.gz
dpkg-native: fix deb-based rootfs construction failure on Fedora 16
Backport a fix from 1.16.x upstream to use fd instead of stream-based I/O in dpkg-deb, which avoids the use of fflush() on an input stream (the behaviour of which is undefined by POSIX, and appears to have changed in the version of glibc introduced in Fedora 16 and presumably other systems). Fixes [YOCTO #1858]. (From OE-Core rev: 2aefac2a2c508da11a73e29d82947ac627d31118) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/dpkg/dpkg/dpkg-deb-avoid-fflush.patch198
-rw-r--r--meta/recipes-devtools/dpkg/dpkg_1.15.8.7.bb5
2 files changed, 201 insertions, 2 deletions
diff --git a/meta/recipes-devtools/dpkg/dpkg/dpkg-deb-avoid-fflush.patch b/meta/recipes-devtools/dpkg/dpkg/dpkg-deb-avoid-fflush.patch
new file mode 100644
index 0000000000..a5d6b616c0
--- /dev/null
+++ b/meta/recipes-devtools/dpkg/dpkg/dpkg-deb-avoid-fflush.patch
@@ -0,0 +1,198 @@
1From 78eaf928d30d0b16e05d8d63c55a3632a135ed9a Mon Sep 17 00:00:00 2001
2From: Guillem Jover <guillem@debian.org>
3Date: Thu, 4 Nov 2010 00:51:13 +0100
4Subject: [PATCH] dpkg-deb: Use fd instead of stream based buffered I/O
5
6Behaviour of fflush() on input streams is undefined per POSIX, avoid
7mixing stream and file descriptor based I/O, and only use the latter
8instead.
9
10Upstream-Status: Backport of revision 2d420ee1d05033d237462a0075facfe406b08043 (in 1.16.x)
11
12---
13 dpkg-deb/extract.c | 83 ++++++++++++++++++++++++++++++++++++++-------------
14 1 files changed, 62 insertions(+), 21 deletions(-)
15
16diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
17index 22aea98..0f5ac88 100644
18--- a/dpkg-deb/extract.c
19+++ b/dpkg-deb/extract.c
20@@ -31,6 +31,7 @@
21 #include <ctype.h>
22 #include <string.h>
23 #include <dirent.h>
24+#include <fcntl.h>
25 #include <unistd.h>
26 #include <ar.h>
27 #include <stdbool.h>
28@@ -61,13 +62,41 @@ static void movecontrolfiles(const char *thing) {
29 }
30
31 static void DPKG_ATTR_NORET
32-readfail(FILE *a, const char *filename, const char *what)
33+read_fail(int rc, const char *filename, const char *what)
34 {
35- if (ferror(a)) {
36- ohshite(_("error reading %s from file %.255s"), what, filename);
37- } else {
38+ if (rc == 0)
39 ohshit(_("unexpected end of file in %s in %.255s"),what,filename);
40+ else
41+ ohshite(_("error reading %s from file %.255s"), what, filename);
42+}
43+
44+static ssize_t
45+read_line(int fd, char *buf, size_t min_size, size_t max_size)
46+{
47+ ssize_t line_size = 0;
48+ size_t n = min_size;
49+
50+ while (line_size < (ssize_t)max_size) {
51+ ssize_t r;
52+ char *nl;
53+
54+ r = read(fd, buf + line_size, n);
55+ if (r <= 0)
56+ return r;
57+
58+ nl = strchr(buf + line_size, '\n');
59+ line_size += r;
60+
61+ if (nl != NULL) {
62+ nl[1] = '\0';
63+ return line_size;
64+ }
65+
66+ n = 1;
67 }
68+
69+ buf[line_size] = '\0';
70+ return line_size;
71 }
72
73 static size_t
74@@ -115,19 +144,26 @@ void extracthalf(const char *debar, const char *directory,
75 char versionbuf[40];
76 float versionnum;
77 size_t ctrllennum, memberlen= 0;
78+ ssize_t r;
79 int dummy;
80 pid_t c1=0,c2,c3;
81 int p1[2], p2[2];
82- FILE *ar;
83+ int arfd;
84 struct stat stab;
85 char nlc;
86 int adminmember;
87 bool oldformat, header_done;
88 struct compressor *decompressor = &compressor_gzip;
89
90- ar= fopen(debar,"r"); if (!ar) ohshite(_("failed to read archive `%.255s'"),debar);
91- if (fstat(fileno(ar),&stab)) ohshite(_("failed to fstat archive"));
92- if (!fgets(versionbuf,sizeof(versionbuf),ar)) readfail(ar,debar,_("version number"));
93+ arfd = open(debar, O_RDONLY);
94+ if (arfd < 0)
95+ ohshite(_("failed to read archive `%.255s'"), debar);
96+ if (fstat(arfd, &stab))
97+ ohshite(_("failed to fstat archive"));
98+
99+ r = read_line(arfd, versionbuf, strlen(DPKG_AR_MAGIC), sizeof(versionbuf));
100+ if (r < 0)
101+ read_fail(r, debar, _("archive magic version number"));
102
103 if (!strcmp(versionbuf, DPKG_AR_MAGIC)) {
104 oldformat = false;
105@@ -137,8 +173,9 @@ void extracthalf(const char *debar, const char *directory,
106 for (;;) {
107 struct ar_hdr arh;
108
109- if (fread(&arh,1,sizeof(arh),ar) != sizeof(arh))
110- readfail(ar,debar,_("between members"));
111+ r = read(arfd, &arh, sizeof(arh));
112+ if (r != sizeof(arh))
113+ read_fail(r, debar, _("archive member header"));
114
115 dpkg_ar_normalize_name(&arh);
116
117@@ -153,8 +190,9 @@ void extracthalf(const char *debar, const char *directory,
118 if (strncmp(arh.ar_name, DEBMAGIC, sizeof(arh.ar_name)) != 0)
119 ohshit(_("file `%.250s' is not a debian binary archive (try dpkg-split?)"),debar);
120 infobuf= m_malloc(memberlen+1);
121- if (fread(infobuf,1, memberlen + (memberlen&1), ar) != memberlen + (memberlen&1))
122- readfail(ar,debar,_("header info member"));
123+ r = read(arfd, infobuf, memberlen + (memberlen & 1));
124+ if ((size_t)r != (memberlen + (memberlen & 1)))
125+ read_fail(r, debar, _("archive information header member"));
126 infobuf[memberlen] = '\0';
127 cur= strchr(infobuf,'\n');
128 if (!cur) ohshit(_("archive has no newlines in header"));
129@@ -174,7 +212,8 @@ void extracthalf(const char *debar, const char *directory,
130 /* Members with `_' are noncritical, and if we don't understand them
131 * we skip them.
132 */
133- stream_null_copy(ar, memberlen + (memberlen&1),_("skipped member data from %s"), debar);
134+ fd_null_copy(arfd, memberlen + (memberlen & 1),
135+ _("skipped archive member data from %s"), debar);
136 } else {
137 if (strncmp(arh.ar_name, ADMINMEMBER, sizeof(arh.ar_name)) == 0)
138 adminmember = 1;
139@@ -198,7 +237,8 @@ void extracthalf(const char *debar, const char *directory,
140 ctrllennum= memberlen;
141 }
142 if (!adminmember != !admininfo) {
143- stream_null_copy(ar, memberlen + (memberlen&1),_("skipped member data from %s"), debar);
144+ fd_null_copy(arfd, memberlen + (memberlen & 1),
145+ _("skipped archive member data from %s"), debar);
146 } else {
147 break; /* Yes ! - found it. */
148 }
149@@ -221,8 +261,10 @@ void extracthalf(const char *debar, const char *directory,
150 l = strlen(versionbuf);
151 if (l && versionbuf[l - 1] == '\n')
152 versionbuf[l - 1] = '\0';
153- if (!fgets(ctrllenbuf,sizeof(ctrllenbuf),ar))
154- readfail(ar, debar, _("control information length"));
155+
156+ r = read_line(arfd, ctrllenbuf, 1, sizeof(ctrllenbuf));
157+ if (r < 0)
158+ read_fail(r, debar, _("archive control member size"));
159 if (sscanf(ctrllenbuf,"%zi%c%d",&ctrllennum,&nlc,&dummy) !=2 || nlc != '\n')
160 ohshit(_("archive has malformatted control length `%s'"), ctrllenbuf);
161
162@@ -230,7 +272,8 @@ void extracthalf(const char *debar, const char *directory,
163 memberlen = ctrllennum;
164 } else {
165 memberlen = stab.st_size - ctrllennum - strlen(ctrllenbuf) - l;
166- stream_null_copy(ar, ctrllennum, _("skipped control area from %s"), debar);
167+ fd_null_copy(arfd, ctrllennum,
168+ _("skipped archive control member data from %s"), debar);
169 }
170
171 if (admininfo >= 2) {
172@@ -252,13 +295,11 @@ void extracthalf(const char *debar, const char *directory,
173
174 }
175
176- safe_fflush(ar);
177-
178 m_pipe(p1);
179 c1 = subproc_fork();
180 if (!c1) {
181 close(p1[0]);
182- stream_fd_copy(ar, p1[1], memberlen, _("failed to write to pipe in copy"));
183+ fd_fd_copy(arfd, p1[1], memberlen, _("failed to write to pipe in copy"));
184 if (close(p1[1]))
185 ohshite(_("failed to close pipe in copy"));
186 exit(0);
187@@ -275,7 +316,7 @@ void extracthalf(const char *debar, const char *directory,
188 decompress_filter(decompressor, 0, 1, _("data"));
189 }
190 close(p1[0]);
191- fclose(ar);
192+ close(arfd);
193 if (taroption) close(p2[1]);
194
195 if (taroption && directory) {
196--
1971.7.7.6
198
diff --git a/meta/recipes-devtools/dpkg/dpkg_1.15.8.7.bb b/meta/recipes-devtools/dpkg/dpkg_1.15.8.7.bb
index f1030faf94..1e7ef25be9 100644
--- a/meta/recipes-devtools/dpkg/dpkg_1.15.8.7.bb
+++ b/meta/recipes-devtools/dpkg/dpkg_1.15.8.7.bb
@@ -5,10 +5,11 @@ SRC_URI += "file://noman.patch \
5 file://check_snprintf.patch \ 5 file://check_snprintf.patch \
6 file://check_version.patch \ 6 file://check_version.patch \
7 file://perllibdir.patch \ 7 file://perllibdir.patch \
8 file://preinst.patch" 8 file://preinst.patch \
9 file://dpkg-deb-avoid-fflush.patch"
9 10
10SRC_URI[md5sum] = "d1731d4147c1ea3b537a4d094519a6dc" 11SRC_URI[md5sum] = "d1731d4147c1ea3b537a4d094519a6dc"
11SRC_URI[sha256sum] = "1ec1376471b04717a4497e5d7a27cd545248c92116898ce0c53ced8ea94267b5" 12SRC_URI[sha256sum] = "1ec1376471b04717a4497e5d7a27cd545248c92116898ce0c53ced8ea94267b5"
12 13
13PR = "${INC_PR}.3" 14PR = "${INC_PR}.4"
14 15