summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-07-26 14:10:58 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-07-26 14:23:49 +0300
commit003e7135024b08b6f29ba83935b468c8f0b41ad4 (patch)
tree9e67d64b9e8a30b8718b339a5171d2e339f4e5d7
parent083ea5a13b421dc8d97283df918abb81a4e21e88 (diff)
downloadapk-tools-003e7135024b08b6f29ba83935b468c8f0b41ad4.tar.gz
apk-tools-003e7135024b08b6f29ba83935b468c8f0b41ad4.tar.bz2
apk-tools-003e7135024b08b6f29ba83935b468c8f0b41ad4.tar.xz
apk-tools-003e7135024b08b6f29ba83935b468c8f0b41ad4.zip
adb: fix some error handling paths
-rw-r--r--src/adb.c14
-rw-r--r--src/app_extract.c2
-rw-r--r--src/io.c2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/adb.c b/src/adb.c
index 1fc135c..a687aba 100644
--- a/src/adb.c
+++ b/src/adb.c
@@ -97,11 +97,11 @@ static int __adb_m_parse(struct adb *db, apk_blob_t data, struct apk_trust *t,
allowed = BIT(ADB_BLOCK_SIG) | BIT(ADB_BLOCK_DATA) | BIT(ADB_BLOCK_DATAX);
if (b.len < 16) {
r = -APKE_ADB_BLOCK;
- break;
+ goto err;
}
if (((struct adb_hdr*)b.ptr)->adb_compat_ver != 0) {
r = -APKE_ADB_VERSION;
- break;
+ goto err;
}
db->adb = b;
break;
@@ -116,7 +116,7 @@ static int __adb_m_parse(struct adb *db, apk_blob_t data, struct apk_trust *t,
break;
case ADB_BLOCK_DATAX:
r = -APKE_ADB_BLOCK;
- break;
+ goto err;
}
r = cb(db, blk, apk_istream_from_blob(&is, b));
if (r < 0) break;
@@ -206,12 +206,12 @@ static int __adb_m_stream(struct adb *db, struct apk_istream *is, uint32_t expec
db->adb.len = adb_block_length(&blk);
if (db->adb.len < 16) {
r = -APKE_ADB_BLOCK;
- break;
+ goto err;
}
if ((r = apk_istream_read(is, db->adb.ptr, sz)) < 0) goto err;
if (((struct adb_hdr*)db->adb.ptr)->adb_compat_ver != 0) {
r = -APKE_ADB_VERSION;
- break;
+ goto err;
}
r = cb(db, &blk, apk_istream_from_blob(&seg.is, db->adb));
if (r < 0) goto err;
@@ -232,7 +232,7 @@ static int __adb_m_stream(struct adb *db, struct apk_istream *is, uint32_t expec
break;
case ADB_BLOCK_DATAX:
r = -APKE_ADB_BLOCK;
- break;
+ goto err;
}
apk_istream_segment(&seg, is, sz, 0);
@@ -456,7 +456,7 @@ struct adb_obj *adb_ro_obj(const struct adb_obj *o, unsigned i, struct adb_obj *
schema = container_of(o->schema->fields[0].kind, struct adb_object_schema, kind);
else if (i > 0 && i < o->schema->num_fields)
schema = container_of(o->schema->fields[i-1].kind, struct adb_object_schema, kind);
- assert(schema->kind == ADB_KIND_OBJECT || schema->kind == ADB_KIND_ARRAY);
+ assert(schema && (schema->kind == ADB_KIND_OBJECT || schema->kind == ADB_KIND_ARRAY));
}
return adb_r_obj(o->db, adb_ro_val(o, i), no, schema);
diff --git a/src/app_extract.c b/src/app_extract.c
index aa5d8aa..662fb81 100644
--- a/src/app_extract.c
+++ b/src/app_extract.c
@@ -341,7 +341,7 @@ static int extract_main(void *pctx, struct apk_ctx *ac, struct apk_string_array
struct extract_ctx *ctx = pctx;
struct apk_out *out = &ac->out;
char **parg;
- int r;
+ int r = 0;
ctx->ac = ac;
ctx->extract_flags |= APK_EXTRACTF_NO_OVERWRITE;
diff --git a/src/io.c b/src/io.c
index 9acf1e6..d78959b 100644
--- a/src/io.c
+++ b/src/io.c
@@ -174,7 +174,7 @@ int apk_istream_get_max(struct apk_istream *is, size_t max, apk_blob_t *data)
int apk_istream_get_delim(struct apk_istream *is, apk_blob_t token, apk_blob_t *data)
{
apk_blob_t ret = APK_BLOB_NULL, left = APK_BLOB_NULL;
- int r;
+ int r = 0;
do {
if (apk_blob_split(APK_BLOB_PTR_LEN((char*)is->ptr, is->end - is->ptr), token, &ret, &left))