summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-05-03 02:38:41 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-05-03 02:38:41 (EDT)
commitb416b15eb246444a30ed5fdea79f45dfe8cc4eab (patch)
tree86450a79b3c7f51a585da055c68d4d6a45d441f8
parentb8b82eb1afebf27a79f39f9da51a32fe52b1a4d9 (diff)
opk/read: Separate error handling
Only free member if opkg_opk_ustar_list() succeeds.
-rw-r--r--src/opk/read.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/opk/read.c b/src/opk/read.c
index a076dae..97187dc 100644
--- a/src/opk/read.c
+++ b/src/opk/read.c
@@ -493,8 +493,13 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name)
}
/* Check package version. */
- if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK ||
- strcmp(member->name, "debian-binary") != 0) {
+ if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK) {
+ fputs(_("Error: Failed to find \"debian-binary\" in archive\n"),
+ stderr);
+ ret = OPKG_OPK_ERROR;
+ goto out3;
+ }
+ if (strcmp(member->name, "debian-binary") != 0) {
free(member);
fputs(_("Error: Failed to find \"debian-binary\" in archive\n"),
stderr);
@@ -510,16 +515,19 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name)
ret = OPKG_OPK_ERROR;
goto out3;
}
- if (version_size < 4 || strncmp(version_buffer, "2.", 2) != 0)
- {
+ if (version_size < 4 || strncmp(version_buffer, "2.", 2) != 0) {
fputs(_("Error: Unsupported package version\n"), stderr);
ret = OPKG_OPK_ERROR;
goto out3;
}
/* Read control archive. */
- if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK ||
- strcmp(member->name, "control.tar.gz") != 0) {
+ if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK) {
+ fputs(_("Error: Failed to find \"control.tar.gz\" in archive\n")
+ , stderr);
+ return OPKG_OPK_ERROR;
+ }
+ if (strcmp(member->name, "control.tar.gz") != 0) {
free(member);
fputs(_("Error: Failed to find \"control.tar.gz\" in archive\n")
, stderr);
@@ -532,8 +540,12 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name)
}
/* Read data archive. */
- if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK ||
- strcmp(member->name, "data.tar.gz") != 0) {
+ if (opkg_opk_ustar_list(opk->outer_ustar, &member) != OPKG_OPK_OK) {
+ fputs(_("Error: Failed to find \"data.tar.gz\" in archive\n"),
+ stderr);
+ return OPKG_OPK_ERROR;
+ }
+ if (strcmp(member->name, "data.tar.gz") != 0) {
free(member);
fputs(_("Error: Failed to find \"data.tar.gz\" in archive\n"),
stderr);