/[packages]/updates/1/rpm/current/SOURCES/rpm-4.8.1-kill-libio.patch
ViewVC logotype

Annotation of /updates/1/rpm/current/SOURCES/rpm-4.8.1-kill-libio.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 216262 - (hide annotations) (download)
Wed Feb 29 21:55:50 2012 UTC (12 years, 1 month ago) by pterjan
File size: 5341 byte(s)
- Backport kill-libio patch (Bug #1962)
1 tv 195416 From: Panu Matilainen
2     Date: 22 Nov 2011
3    
4     Right... I had forgotten just how much had changed in this area since 4.9.x and just how broken things had been.
5    
6     The header reading IO has been hardwired to ufdio (see timedRead() in rpmio.c) for pretty much all of its life, eliminating any possibility of compressed io working. The other piece of the puzzle is rpm's libio usage which affects the rpm io semantics to vary between fread() and read() styles. Which the header stuff can't cope with, hence the hardwire to ufdio.
7    
8     The attached patch makes my previous code snippet to read headers directly from compressed stream work on rpm-4.9.x too. It's essentially commit 3ab3a931b4dd84eedcb35229187e5be8d14f9418 from master + unconditionally disable libio usage. Rpm itself should be ok with this change as is (at least the test-suite still passes) but I can't guarantee it wont break anything else in your setup. Eg if you have code that's tuned to the exact semantics it had before... but then again it might just as well fix some "mysteriously broken things" for you.
9    
10 pterjan 216262 diff -up rpm-4.8.1/lib/header.c.0160 rpm-4.8.1/lib/header.c
11     --- rpm-4.8.1/lib/header.c.0160 2012-02-29 22:46:17.717223536 +0100
12     +++ rpm-4.8.1/lib/header.c 2012-02-29 22:46:17.727223566 +0100
13     @@ -962,8 +962,7 @@ Header headerRead(FD_t fd, enum hMagic m
14 tv 195416 if (magicp == HEADER_MAGIC_YES)
15     i += 2;
16    
17     - /* FIX: cast? */
18     - if (timedRead(fd, (char *)block, i*sizeof(*block)) != (i * sizeof(*block)))
19     + if (Fread(block, 1, i*sizeof(*block), fd) != i*sizeof(*block))
20     goto exit;
21    
22     i = 0;
23 pterjan 216262 @@ -989,8 +988,7 @@ Header headerRead(FD_t fd, enum hMagic m
24 tv 195416 ei[1] = htonl(dl);
25     len -= sizeof(il) + sizeof(dl);
26    
27     - /* FIX: cast? */
28     - if (timedRead(fd, (char *)&ei[2], len) != len)
29     + if (Fread((char *)&ei[2], 1, len, fd) != len)
30     goto exit;
31    
32     h = headerLoad(ei);
33 pterjan 216262 diff -up rpm-4.8.1/lib/package.c.0160 rpm-4.8.1/lib/package.c
34     --- rpm-4.8.1/lib/package.c.0160 2010-06-11 10:45:34.000000000 +0200
35     +++ rpm-4.8.1/lib/package.c 2012-02-29 22:46:17.727223566 +0100
36     @@ -468,7 +468,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring
37 tv 195416 *msg = NULL;
38    
39     memset(block, 0, sizeof(block));
40     - if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
41     + if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) {
42     rasprintf(&buf,
43     _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
44     goto exit;
45 pterjan 216262 @@ -494,7 +494,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring
46 tv 195416 ei = xmalloc(uc);
47     ei[0] = block[2];
48     ei[1] = block[3];
49     - if ((xx = timedRead(fd, (char *)&ei[2], nb)) != nb) {
50     + if ((xx = Fread((char *)&ei[2], 1, nb, fd)) != nb) {
51     rasprintf(&buf, _("hdr blob(%zd): BAD, read returned %d\n"), nb, xx);
52     goto exit;
53     }
54 pterjan 216262 diff -up rpm-4.8.1/lib/rpmlead.c.0160 rpm-4.8.1/lib/rpmlead.c
55     --- rpm-4.8.1/lib/rpmlead.c.0160 2010-06-11 10:45:34.000000000 +0200
56     +++ rpm-4.8.1/lib/rpmlead.c 2012-02-29 22:46:17.727223566 +0100
57     @@ -117,8 +117,7 @@ rpmRC rpmLeadRead(FD_t fd, rpmlead lead)
58 tv 195416 {
59     assert(lead != NULL);
60     memset(lead, 0, sizeof(*lead));
61     - /* FIX: remove timed read */
62     - if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
63     + if (Fread(lead, 1, sizeof(*lead), fd) != sizeof(*lead)) {
64     if (Ferror(fd)) {
65     rpmlog(RPMLOG_ERR, _("read failed: %s (%d)\n"),
66     Fstrerror(fd), errno);
67 pterjan 216262 diff -up rpm-4.8.1/lib/signature.c.0160 rpm-4.8.1/lib/signature.c
68     --- rpm-4.8.1/lib/signature.c.0160 2009-12-07 15:36:49.000000000 +0100
69     +++ rpm-4.8.1/lib/signature.c 2012-02-29 22:46:17.727223566 +0100
70     @@ -124,7 +124,7 @@ rpmRC rpmReadSignature(FD_t fd, Header *
71 tv 195416 goto exit;
72    
73     memset(block, 0, sizeof(block));
74     - if ((xx = timedRead(fd, (void *)block, sizeof(block))) != sizeof(block)) {
75     + if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) {
76     rasprintf(&buf, _("sigh size(%d): BAD, read returned %d\n"),
77     (int)sizeof(block), xx);
78     goto exit;
79 pterjan 216262 @@ -155,7 +155,7 @@ rpmRC rpmReadSignature(FD_t fd, Header *
80 tv 195416 ei[1] = block[3];
81     pe = (entryInfo) &ei[2];
82     dataStart = (unsigned char *) (pe + il);
83     - if ((xx = timedRead(fd, (void *)pe, nb)) != nb) {
84     + if ((xx = Fread(pe, 1, nb, fd)) != nb) {
85     rasprintf(&buf,
86     _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx);
87     goto exit;
88 pterjan 216262 @@ -244,7 +244,7 @@ rpmRC rpmReadSignature(FD_t fd, Header *
89 tv 195416 rpm_loff_t archSize = 0;
90    
91     /* Position at beginning of header. */
92     - if (pad && (trc = timedRead(fd, (void *)block, pad)) != pad) {
93     + if (pad && (trc = Fread(block, 1, pad, fd)) != pad) {
94     rasprintf(&buf,
95     _("sigh pad(%zd): BAD, read %zd bytes\n"), pad, trc);
96     goto exit;
97 pterjan 216262 diff -up rpm-4.8.1/rpmio/rpmio.c.0160 rpm-4.8.1/rpmio/rpmio.c
98     --- rpm-4.8.1/rpmio/rpmio.c.0160 2009-12-07 15:36:49.000000000 +0100
99     +++ rpm-4.8.1/rpmio/rpmio.c 2012-02-29 22:46:38.537284284 +0100
100     @@ -5,9 +5,7 @@
101     #include "system.h"
102     #include <stdarg.h>
103 tv 195416
104     -#if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION)
105     -#define _USE_LIBIO 1
106     -#endif
107     +#define _USE_LIBIO 0
108    
109 pterjan 216262 #include <rpm/rpmlog.h>
110     #include <rpm/rpmmacro.h>
111     @@ -765,7 +763,7 @@ static const FDIO_t ufdio = &ufdio_s ;
112 tv 195416
113     ssize_t timedRead(FD_t fd, void * bufptr, size_t length)
114     {
115     - return ufdio->read(fd, bufptr, length);
116     + return Fread(bufptr, 1, length, fd);
117     }
118    
119     /* =============================================================== */

  ViewVC Help
Powered by ViewVC 1.1.30