blob: 48340498d9bc320db26b1a8d4bf2551e4572e209 (
plain)
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
|
--- vamps-0.99.2/vamps/vamps.c.orig 2006-04-15 08:00:07.000000000 -0400
+++ vamps-0.99.2/vamps/vamps.c 2007-01-26 06:54:27.000000000 -0500
@@ -18,6 +18,9 @@
//
// Revision history (latest first):
//
+// 2007/01/26: V0.99.3: Fixed assumptions in lock() which do not hold for pipes.
+// This cures the "Premature EOF" problem.
+//
// 2006/04/15: V0.99.2: Fixed some signed/unsigned issues which caused compiler
// warnings on some platforms. No funtional changes.
//
@@ -396,13 +399,24 @@
rhwp = rptr + avail;
}
- n = read (0, rhwp, RBUF_SIZE - avail);
-
- if (n % SECT_SIZE)
- fatal ("Premature EOF");
-
- rhwp += n;
- bytes_read += n;
+ while (avail < size)
+ {
+ // read; reads from an open pipe will return any non-zero amount of data
+ // (not necessarily the amount we wanted!)
+ n = read (0, rhwp, RBUF_SIZE - avail);
+ if (!n)
+ {
+ if (avail % SECT_SIZE)
+ // we got an EOF and only a partial sector
+ fatal ("Premature EOF");
+ break;
+ }
+ else if (n == -1)
+ fatal ("Read from stdin: %s", strerror (errno));
+ rhwp += n;
+ bytes_read += n;
+ avail += n;
+ }
return !n;
}
|