summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/adb.c5
-rw-r--r--src/adb_comp.c5
2 files changed, 7 insertions, 3 deletions
diff --git a/src/adb.c b/src/adb.c
index 69b58fb..1fc135c 100644
--- a/src/adb.c
+++ b/src/adb.c
@@ -257,7 +257,10 @@ err:
int adb_m_process(struct adb *db, struct apk_istream *is, uint32_t expected_schema,
struct apk_trust *t, int (*cb)(struct adb *, struct adb_block *, struct apk_istream *))
{
- apk_blob_t mmap = apk_istream_mmap(is);
+ apk_blob_t mmap;
+
+ if (IS_ERR(is)) return PTR_ERR(is);
+ mmap = apk_istream_mmap(is);
memset(db, 0, sizeof *db);
if (expected_schema & ADB_SCHEMA_IMPLIED)
db->schema = expected_schema & ~ADB_SCHEMA_IMPLIED;
diff --git a/src/adb_comp.c b/src/adb_comp.c
index b697101..26fb50f 100644
--- a/src/adb_comp.c
+++ b/src/adb_comp.c
@@ -11,13 +11,14 @@
struct apk_istream *adb_decompress(struct apk_istream *is, adb_comp_t *compression)
{
- adb_comp_t c = -1;
+ adb_comp_t c = -1;
if (IS_ERR_OR_NULL(is)) return is;
uint8_t *buf = apk_istream_peek(is, 4);
if (IS_ERR(buf)) return ERR_PTR(apk_istream_close_error(is, PTR_ERR(buf)));
- if (memcmp(buf, "ADB", 3) == 0) switch (buf[3]) {
+ if (memcmp(buf, "ADB", 3) != 0) return ERR_PTR(apk_istream_close_error(is, -APKE_ADB_HEADER));
+ switch (buf[3]) {
case '.':
c = ADB_COMP_NONE;
break;