summaryrefslogtreecommitdiff
path: root/src/adb.c
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 /src/adb.c
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
Diffstat (limited to 'src/adb.c')
-rw-r--r--src/adb.c14
1 files changed, 7 insertions, 7 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);