diff options
author | Richard Hughes <richard@hughsie.com> | 2017-12-29 20:51:28 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2017-12-29 20:51:53 +0000 |
commit | f5465c956afdf60a0bac2d809dca6fc2fdc9aa7f (patch) | |
tree | 1dc58f24a3fa2374bcddcb4cd59e2defde213019 | |
parent | d530be420c61be3755f26f1471ca1d843af831ad (diff) | |
download | gcab-wip/hughsie/bzero.tar.gz |
Add a command line argument to restrict the size of the loaded archivewip/hughsie/bzero
-rw-r--r-- | src/gcab.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -30,6 +30,7 @@ typedef struct { gboolean verbose; guint32 max_file_size; + guint32 max_archive_size; GFile * cwd; } GCabSelf; @@ -147,6 +148,7 @@ main (int argc, char *argv[]) { "zip", 'z', 0, G_OPTION_ARG_NONE, &compress, N_("Use zip compression"), NULL }, { "nopath", 'n', 0, G_OPTION_ARG_NONE, &nopath, N_("Do not include path"), NULL }, { "max-file-size", '\0', 0, G_OPTION_ARG_INT, &self->max_file_size, N_("Maximum size of each decompressed file"), NULL }, + { "max-archive-size", '\0', 0, G_OPTION_ARG_INT, &self->max_archive_size, N_("Maximum size compressed archive"), NULL }, { "space", 's', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_INT, &space, N_("Reserve space in cabinet for signing (e.g. -s 6144 reserves 6K bytes)"), NULL }, { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, N_("FILE INPUT_FILES...") }, { NULL } @@ -209,6 +211,15 @@ individual files from the archive.\ g_printerr ("%s %s: %s\n", _("Error reading"), args[0], error->message); return EXIT_FAILURE; } + if (self->max_archive_size > 0 && + gcab_cabinet_get_size (cabinet) > self->max_archive_size) { + g_autofree gchar *sz_str = NULL; + sz_str = g_format_size_full (self->max_archive_size, G_FORMAT_SIZE_LONG_FORMAT); + g_printerr ("%s: %s\n", + _("Cannot open file as larger than maximum size"), + sz_str); + return EXIT_FAILURE; + } if (list || list_details) { GPtrArray *folders = gcab_cabinet_get_folders (cabinet); |