summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-17 17:33:53 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-17 17:40:56 (EDT)
commitcd490b6ff02d1cea5390760f457b73495661c73f (patch)
tree0257a4348ffc296abd0844cee8130247b0764e96 /src
parente821204c4d9e9eb46ef573e5ec8548dee37ea5bf (diff)
ustar: Verify typeflag
Diffstat (limited to 'src')
-rw-r--r--src/ustar.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/ustar.c b/src/ustar.c
index c183560..4cc4651 100644
--- a/src/ustar.c
+++ b/src/ustar.c
@@ -114,10 +114,26 @@ _opkg_opk_ustar_next(struct opkg_opk_ustar *ustar,
return OPKG_OPK_ERROR;
}
- ustar->data_size_remaining = strtol((char *) header->size, &end,
- OPKG_OPK_USTAR_NUM_BASE_);
- if (*end != '\0') {
- return OPKG_OPK_ERROR;
+ switch (*header->typeflag) {
+ case '0': /* Regular file */
+ case '7': /* High-performance or regular file */
+ ustar->data_size_remaining = strtol(
+ (char *) header->size, &end,
+ OPKG_OPK_USTAR_NUM_BASE_);
+ if (*end != '\0') {
+ return OPKG_OPK_ERROR;
+ }
+ break;
+ case '2': /* Symbolic link */
+ case '3': /* Character special file */
+ case '4': /* Block special file */
+ case '5': /* Directory */
+ case '6': /* FIFO special file */
+ ustar->data_size_remaining = 0;
+ break;
+ case '1': /* Link */
+ default: /* Reserved */
+ return OPKG_OPK_ERROR; /* Unsupported */
}
return OPKG_OPK_OK;