]>
Commit | Line | Data |
---|---|---|
54f01803 | 1 | --- poldek-0.18.8/trurlib/nstream.c.orig 2004-05-06 09:57:45.000000000 +0200 |
a2a4c30f | 2 | +++ poldek-0.18.8/trurlib/nstream.c 2005-04-12 10:42:44.000000000 +0200 |
54f01803 JB |
3 | @@ -57,8 +57,10 @@ |
4 | z_off_t rc, off = *offset; | |
5 | ||
6 | rc = gzseek(stream, off, whence); | |
7 | - if (rc >= 0) | |
8 | + if (rc >= 0) { | |
9 | + *offset = rc; | |
10 | rc = 0; | |
11 | + } | |
12 | #if ZLIB_TRACE | |
13 | printf("zfseek (%p, %ld, %lld, %d) = %d\n", stream, off, *offset, whence, rc); | |
14 | #endif | |
15 | @@ -281,7 +283,7 @@ | |
16 | ||
17 | } else { | |
18 | st->stream = stream; | |
19 | - fseek(st->stream, 0, SEEK_SET); /* glibc BUG (?) */ | |
20 | + fseek(st->stream, 0, SEEK_SET); /* XXX glibc BUG (?) */ | |
21 | st->type = type; | |
22 | }; | |
23 | break; | |
a2a4c30f JB |
24 | --- poldek-0.18.8/vfile/vfile.c.orig 2005-04-07 15:38:06.000000000 +0200 |
25 | +++ poldek-0.18.8/vfile/vfile.c 2005-04-12 10:36:43.000000000 +0200 | |
26 | @@ -130,8 +130,10 @@ | |
27 | z_off_t rc, off = *offset; | |
28 | ||
29 | rc = gzseek(stream, off, whence); | |
30 | - if (rc >= 0) | |
31 | + if (rc >= 0) { | |
32 | + *offset = rc; | |
33 | rc = 0; | |
34 | + } | |
35 | #if ZLIB_TRACE | |
36 | printf("zfseek (%p, %ld, %lld, %d) = %d\n", stream, off, *offset, whence, rc); | |
37 | #endif | |
38 | @@ -349,7 +351,16 @@ | |
39 | vf->vf_stream = fopencookie(gzstream, mode, gzio_cookie); | |
40 | if (vf->vf_stream != NULL) { | |
41 | rc = 1; | |
42 | - fseek(vf->vf_stream, 0, SEEK_SET); /* glibc BUG (?) */ | |
43 | + vf->vf_buf = malloc(128); /* use small buffer to avoid reverse gzseeks on small forward fseeks */ | |
44 | + if(vf->vf_buf == NULL) | |
45 | + vfile_err_fn("buffer malloc failed for %s\n", CL_URL(path)); | |
46 | + else | |
47 | + if(setvbuf(vf->vf_stream, vf->vf_buf, _IOFBF, 128) != 0) { | |
48 | + vfile_err_fn("setvbuf failed for %s\n", CL_URL(path)); | |
49 | + free(vf->vf_buf); | |
50 | + vf->vf_buf = NULL; | |
51 | + } | |
52 | + fseek(vf->vf_stream, 0, SEEK_SET); /* XXX glibc BUG (?) */ | |
53 | } else | |
54 | vfile_err_fn("fopencookie %s: hgw error\n", CL_URL(path)); | |
55 | ||
56 | @@ -489,6 +500,7 @@ | |
57 | vf.vf_type = vftype; | |
58 | vf.vf_mode = vfmode; | |
59 | vf.vf_flags = 0; | |
60 | + vf.vf_buf = NULL; | |
61 | ||
62 | urltype = vf_url_type(path); | |
63 | opened = 0; | |
64 | @@ -686,6 +698,8 @@ | |
65 | free(vf->vf_tmpath); | |
66 | vf->vf_tmpath = NULL; | |
67 | } | |
68 | + if (vf->vf_buf) | |
69 | + free(vf->vf_buf); | |
70 | memset(vf, 0, sizeof(*vf)); | |
71 | free(vf); | |
72 | } | |
73 | --- poldek-0.18.8/vfile/vfile.h.orig 2005-04-07 15:38:06.000000000 +0200 | |
74 | +++ poldek-0.18.8/vfile/vfile.h 2005-04-12 10:36:43.000000000 +0200 | |
75 | @@ -81,6 +81,7 @@ | |
76 | ||
77 | char *vf_path; | |
78 | char *vf_tmpath; | |
79 | + char *vf_buf; | |
80 | int16_t _refcnt; | |
81 | }; | |
82 | ||
83 | --- poldek-0.18.8/pkgfl.c.orig 2004-12-30 13:05:22.000000000 +0100 | |
84 | +++ poldek-0.18.8/pkgfl.c 2005-04-12 09:47:22.000000000 +0200 | |
85 | @@ -530,7 +530,7 @@ | |
86 | tn_buf *nbuf; | |
87 | tn_buf_it nbufi; | |
88 | uint32_t size; | |
89 | - char *buf; | |
90 | + char *buf, dummy; | |
91 | ||
92 | if (fread(&size, sizeof(size), 1, stream) != 1) | |
93 | return NULL; | |
94 | @@ -548,7 +548,7 @@ | |
95 | fl = pkgfl_restore(&nbufi, dirs, include); | |
96 | n_buf_free(nbuf); | |
97 | ||
98 | - fseek(stream, 1, SEEK_CUR); /* skip final '\n' */ | |
99 | + fread(&dummy, 1, 1, stream); /* skip final '\n' */ | |
100 | ||
101 | return fl; | |
102 | } | |
103 | --- poldek-0.18.8/pkgu.c.orig 2002-05-15 17:42:48.000000000 +0200 | |
104 | +++ poldek-0.18.8/pkgu.c 2005-04-12 09:52:45.000000000 +0200 | |
105 | @@ -239,8 +239,8 @@ | |
106 | { | |
107 | uint16_t nsize, nlangs; | |
108 | ||
109 | - fseek(stream, sizeof(nlangs), SEEK_CUR); | |
110 | - if (fread(&nsize, sizeof(nsize), 1, stream) != 1) { | |
111 | + if ((fread(&nlangs, sizeof(nlangs), 1, stream) != 1) || | |
112 | + (fread(&nsize, sizeof(nsize), 1, stream) != 1)) { | |
113 | nsize = 0; | |
114 | } else { | |
115 | nsize = ntoh16(nsize); | |
cc9ab18b AM |
116 | diff -urN poldek-0.18.8.org/pkgfl.c poldek-0.18.8/pkgfl.c |
117 | --- poldek-0.18.8.org/pkgfl.c 2004-12-30 13:05:22.000000000 +0100 | |
118 | +++ poldek-0.18.8/pkgfl.c 2005-04-20 23:21:45.000000000 +0200 | |
119 | @@ -557,12 +557,15 @@ | |
120 | int pkgfl_skip_f(FILE *stream) | |
121 | { | |
122 | uint32_t size; | |
123 | + char *buf; | |
124 | ||
125 | if (fread(&size, sizeof(size), 1, stream) != 1) | |
126 | return 0; | |
127 | ||
128 | size = ntoh32(size); | |
129 | - fseek(stream, size + 1, SEEK_CUR); | |
130 | + /* skip size + 1 bytes */ | |
131 | + buf = alloca(size + 1); | |
132 | + fread(buf, 1, size + 1, stream); | |
133 | return 1; | |
134 | } | |
135 | ||
136 |