summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/main.c b/src/main.c
index 7d554f5..a24f3de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -59,49 +59,56 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member,
file.file = fopen(file_name, "rb");
if (file.file == NULL) {
- return OPKG_OPK_ERROR;
+ goto error0;
}
outer_gzip = opkg_opk_gzip_init(&_opkg_opk_main_file_read, &file);
if (outer_gzip == NULL) {
- fclose(file.file);
- return OPKG_OPK_ERROR;
+ goto error1;
}
outer_ustar = opkg_opk_ustar_init(outer_gzip);
if (outer_ustar == NULL) {
- opkg_opk_gzip_free(outer_gzip);
- fclose(file.file);
- return OPKG_OPK_ERROR;
+ goto error2;
+ }
+
+ if (opkg_opk_ustar_seek(outer_ustar, outer_member) != OPKG_OPK_OK) {
+ goto error3;
}
- opkg_opk_ustar_seek(outer_ustar, outer_member);
inner_gzip = opkg_opk_gzip_init(&opkg_opk_ustar_read, outer_ustar);
if (inner_gzip == NULL) {
- opkg_opk_ustar_free(outer_ustar);
- opkg_opk_gzip_free(outer_gzip);
- fclose(file.file);
- return OPKG_OPK_ERROR;
+ goto error3;
}
inner_ustar = opkg_opk_ustar_init(inner_gzip);
if (inner_ustar == NULL) {
- opkg_opk_gzip_free(inner_gzip);
- opkg_opk_ustar_free(outer_ustar);
- opkg_opk_gzip_free(outer_gzip);
- fclose(file.file);
- return OPKG_OPK_ERROR;
+ goto error4;
}
- inner_action(inner_ustar);
+ if (inner_action(inner_ustar) != OPKG_OPK_OK) {
+ goto error5;
+ }
opkg_opk_ustar_free(inner_ustar);
opkg_opk_gzip_free(inner_gzip);
opkg_opk_ustar_free(outer_ustar);
opkg_opk_gzip_free(outer_gzip);
fclose(file.file);
-
return OPKG_OPK_OK;
+
+ error5:
+ opkg_opk_ustar_free(inner_ustar);
+ error4:
+ opkg_opk_gzip_free(inner_gzip);
+ error3:
+ opkg_opk_ustar_free(outer_ustar);
+ error2:
+ opkg_opk_gzip_free(outer_gzip);
+ error1:
+ fclose(file.file);
+ error0:
+ return OPKG_OPK_ERROR;
}
static int