diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-18 10:19:58 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-18 10:19:58 (EDT) |
commit | 3366d4988f9f93b0ee0d97bac8277fe83ed8f4ea (patch) | |
tree | 10530e1ab138b4db2d81313d26a01187f4f7932f /src | |
parent | 76ebb2415570162416da64d1136707e02228bb5c (diff) |
main: Check debian-version
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -57,6 +57,8 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member, struct _opkg_opk_main_file file; struct opkg_opk_gzip *outer_gzip; struct opkg_opk_ustar *outer_ustar; + char *buffer; + size_t size; struct opkg_opk_gzip *inner_gzip; struct opkg_opk_ustar *inner_ustar; @@ -79,6 +81,22 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member, goto error2; } + if (opkg_opk_ustar_seek(outer_ustar, 1, "debian-binary") != + OPKG_OPK_OK) { + fputs("Error: Failed to find \"debian-binary\" in archive\n", + stderr); + goto error3; + } + if (opkg_opk_ustar_read(outer_ustar, &buffer, &size) != OPKG_OPK_OK) { + fputs("Error: Failed to read \"debian-binary\" in archive\n", + stderr); + goto error3; + } + if (size < 4 || strncmp(buffer, "2.", 2) != 0) { + fputs("Error: Unsupported package version\n", stderr); + goto error3; + } + if (opkg_opk_ustar_seek(outer_ustar, 1, outer_member) != OPKG_OPK_OK) { fprintf(stderr, "Error: Failed to find \"%s\" in archive\n", outer_member); |