Group :: Terminais
RPM: ttyrec
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: 13_ttyplay_fread.diff
Download
Download
Description: Handle SIGWINCH
Auther: Joey Hess <joeyh@debian.org>
Reported-By: Joey Hess <joeyh@debian.org>
Bug-Debian: http://bugs.debian.org/564931
Reviewed-By: NIIBE Yutaka <gniibe@fsij.org>
Last-Update: 2010-04-27
--- ttyrec-1.0.8.orig/ttyplay.c 2010-04-27 15:22:58.000000000 +0900
+++ ttyrec-1.0.8/ttyplay.c 2010-04-27 15:23:19.000000000 +0900
@@ -151,8 +151,15 @@
int
ttyread (FILE *fp, Header *h, char **buf)
{
+ fpos_t pos;
+ int can_seek=0;
+ if (fgetpos(fp, &pos) == 0) {
+ can_seek=1;
+ }
+ clearerr(fp);
+
if (read_header(fp, h) == 0) {
- return 0;
+ goto err;
}
*buf = malloc(h->len);
@@ -161,9 +168,21 @@
}
if (fread(*buf, 1, h->len, fp) == 0) {
- perror("fread");
+ goto err;
}
return 1;
+
+err:
+ if (ferror(fp)) {
+ perror("fread");
+ }
+ else {
+ /* Short read. Seek back to before header, to set up for retry. */
+ if (can_seek) {
+ fsetpos(fp, &pos);
+ }
+ }
+ return 0;
}
int