summaryrefslogtreecommitdiffstats
path: root/libbb
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-10 01:00:51 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-10 01:00:51 (EST)
commitbc4e5966d81e22dd7ea57ef24025ffdbf9a0bcfd (patch)
tree1d7ff73ad89eb131e8e28122b6d5669d3a3a5b15 /libbb
parentb7c20f70f426a26ca49303ee47b982fe3acc4729 (diff)
Clarify why we're not using fseek(), use fseek() where applicable.
git-svn-id: http://opkg.googlecode.com/svn/trunk@481 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libbb')
-rw-r--r--libbb/unarchive.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index 03a63bd..62ca267 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -61,11 +61,15 @@ seek_by_read(FILE* fd, size_t len)
}
static void
-seek_sub_file(FILE *src_stream, const int count)
+seek_sub_file(FILE *fd, const int count)
{
- /* Try to fseek as faster */
archive_offset += count;
- seek_by_read(src_stream, count);
+
+ /* Do not use fseek() on a pipe. It may fail with ESPIPE, leaving the
+ * stream at an undefined location.
+ */
+ seek_by_read(fd, count);
+
return;
}
@@ -686,7 +690,12 @@ deb_extract(const char *package_filename, FILE *out_stream,
free_header_ar(ar_header);
break;
}
- seek_sub_file(deb_stream, ar_header->size);
+ if (fseek(deb_stream, ar_header->size, SEEK_CUR) == -1) {
+ opkg_perror(ERROR, "Couldn't fseek into %s", package_filename);
+ *err = -1;
+ free_header_ar(ar_header);
+ goto cleanup;
+ }
free_header_ar(ar_header);
}
goto cleanup;
@@ -696,7 +705,11 @@ deb_extract(const char *package_filename, FILE *out_stream,
FILE *unzipped_opkg_stream;
file_header_t *tar_header;
archive_offset = 0;
- fseek(deb_stream, 0, SEEK_SET);
+ if (fseek(deb_stream, 0, SEEK_SET) == -1) {
+ opkg_perror(ERROR, "Couldn't fseek into %s", package_filename);
+ *err = -1;
+ goto cleanup;
+ }
unzipped_opkg_stream = gz_open(deb_stream, &unzipped_opkg_pid);
if (unzipped_opkg_stream == NULL) {
*err = -1;