You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/media-video/vamps/files/vamps-0.99.2-premature-eof....

47 lines
1.2 KiB

--- 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;
}