projects
/
ruby-vorbistagger.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b861e6
)
Check the error flag when reading data.
author
Tilman Sauerbeck
<tilman@code-monkey.de>
Fri, 18 Aug 2006 13:38:30 +0000
(15:38 +0200)
committer
Tilman Sauerbeck
<tilman@code-monkey.de>
Wed, 23 Aug 2006 17:39:15 +0000
(19:39 +0200)
ext/vcedit.c
patch
|
blob
|
history
diff --git
a/ext/vcedit.c
b/ext/vcedit.c
index ce5cb10b56ee9ecadd2a4829b496a2ea990a491a..cf63e7487217c7a36fcb479590328488928c7c63 100644
(file)
--- a/
ext/vcedit.c
+++ b/
ext/vcedit.c
@@
-240,7
+240,7
@@
_fetch_next_packet (vcedit_state *s, ogg_packet *p, ogg_page *page)
bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
- if (!bytes &&
feof (s->in
))
+ if (!bytes &&
(feof (s->in) || ferror (s->in)
))
return 0;
}
return 0;
}
@@
-276,7
+276,7
@@
vcedit_open (vcedit_state *s)
do {
/* Bail if we don't find data in the first 40 kB */
do {
/* Bail if we don't find data in the first 40 kB */
- if (feof (s->in) || total >= (CHUNKSIZE * 10)) {
+ if (feof (s->in) ||
ferror (s->in) ||
total >= (CHUNKSIZE * 10)) {
ogg_sync_clear (&s->oy);
return VCEDIT_ERR_INVAL;
ogg_sync_clear (&s->oy);
return VCEDIT_ERR_INVAL;
@@
-318,6
+318,11
@@
vcedit_open (vcedit_state *s)
header = &header_comments;
while (i < 2) {
header = &header_comments;
while (i < 2) {
+ if (feof (s->in) || ferror (s->in)) {
+ ret = VCEDIT_ERR_INVAL;
+ goto err;
+ }
+
while (i < 2) {
int result;
while (i < 2) {
int result;
@@
-353,13
+358,8
@@
vcedit_open (vcedit_state *s)
}
buffer = ogg_sync_buffer (&s->oy, CHUNKSIZE);
}
buffer = ogg_sync_buffer (&s->oy, CHUNKSIZE);
- bytes = fread (buffer, 1, CHUNKSIZE, s->in);
-
- if (!bytes && feof (s->in) && i < 2) {
- ret = VCEDIT_ERR_INVAL;
- goto err;
- }
+ bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
}
ogg_sync_wrote (&s->oy, bytes);
}
@@
-540,6
+540,9
@@
vcedit_write (vcedit_state *s)
bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
bytes = fread (buffer, 1, CHUNKSIZE, s->in);
ogg_sync_wrote (&s->oy, bytes);
+ if (ferror (s->in))
+ goto cleanup;
+
s->eosin = !bytes && feof (s->in);
} while (!s->eosin);
s->eosin = !bytes && feof (s->in);
} while (!s->eosin);