Skip to content
Commits on Source (8)
Major changes in 0.4.3:
* Prevent NULL dereference when extracting to root (Ondrej Holy)
* Do not include basename in error messages (Ondrej Holy)
* Do not request password when encryption is unsupported (Ignacy Kuchciński)
* Propagate libarchive errors when extraction failed (Ignacy Kuchciński)
Major changes in 0.4.2:
* Fix extraction to root directory (Ondrej Holy)
* Fix extraction of raw format archives (Ondrej Holy)
......
......@@ -97,7 +97,6 @@ G_DEFINE_QUARK (autoar-extractor, autoar_extractor)
#define BUFFER_SIZE (64 * 1024)
#define NOT_AN_ARCHIVE_ERRNO 2013
#define EMPTY_ARCHIVE_ERRNO 2014
#define INCORRECT_PASSPHRASE_ERRNO 2015
typedef struct _GFileAndInfo GFileAndInfo;
......@@ -992,11 +991,13 @@ autoar_extractor_do_write_entry (AutoarExtractor *self,
{
GFile *parent;
parent = g_file_get_parent (dest);
if (parent && !g_file_query_exists (parent, self->cancellable))
g_file_make_directory_with_parents (parent,
self->cancellable,
NULL);
g_object_unref (parent);
if (parent) {
if (!g_file_query_exists (parent, self->cancellable))
g_file_make_directory_with_parents (parent,
self->cancellable,
NULL);
g_object_unref (parent);
}
}
info = g_file_info_new ();
......@@ -1172,12 +1173,9 @@ autoar_extractor_do_write_entry (AutoarExtractor *self,
autoar_extractor_signal_progress (self);
}
if (r == ARCHIVE_FAILED) {
if (r != ARCHIVE_EOF) {
if (self->error == NULL) {
self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
INCORRECT_PASSPHRASE_ERRNO,
"%s",
archive_error_string (a));
self->error = autoar_common_g_error_new_a (a, NULL);
}
g_output_stream_close (ostream, self->cancellable, NULL);
g_object_unref (ostream);
......@@ -1658,18 +1656,16 @@ autoar_extractor_step_scan_toplevel (AutoarExtractor *self)
r = libarchive_create_read_object (TRUE, self, &a);
if (r != ARCHIVE_OK) {
if (self->error == NULL)
self->error = autoar_common_g_error_new_a (a, self->source_basename);
self->error = autoar_common_g_error_new_a (a, NULL);
return;
} else if (archive_filter_count (a) <= 1){
/* If we only use raw format and filter count is one, libarchive will
* not do anything except for just copying the source file. We do not
* want this thing to happen because it does unnecesssary copying. */
if (self->error == NULL)
self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
NOT_AN_ARCHIVE_ERRNO,
"\'%s\': %s",
self->source_basename,
"not an archive");
self->error = g_error_new_literal (AUTOAR_EXTRACTOR_ERROR,
NOT_AN_ARCHIVE_ERRNO,
"not an archive");
return;
}
self->use_raw_format = TRUE;
......@@ -1688,7 +1684,14 @@ autoar_extractor_step_scan_toplevel (AutoarExtractor *self)
return;
}
if (archive_entry_is_encrypted (entry)) {
/* The password is requested only for the ZIP format to avoid showing
* password prompt for 7ZIP/RAR, where archive_entry_is_encrypted resp.
* archive_entry_is_metadata_encrypted returns TRUE, but followup
* archive_read_data_block resp. archive_read_next_header call leads to
* an error. See https://github.com/libarchive/libarchive/issues/1662.
*/
if (archive_entry_is_encrypted (entry) &&
archive_format (a) == ARCHIVE_FORMAT_ZIP) {
autoar_extractor_request_passphrase (self);
if (g_cancellable_is_cancelled (self->cancellable)) {
archive_read_free (a);
......@@ -1725,22 +1728,19 @@ autoar_extractor_step_scan_toplevel (AutoarExtractor *self)
archive_read_data_skip (a);
}
if (self->files_list == NULL) {
if (r != ARCHIVE_EOF) {
if (self->error == NULL) {
self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
EMPTY_ARCHIVE_ERRNO,
"\'%s\': %s",
self->source_basename,
"empty archive");
self->error = autoar_common_g_error_new_a (a, NULL);
}
archive_read_free (a);
return;
}
if (r != ARCHIVE_EOF) {
if (self->files_list == NULL) {
if (self->error == NULL) {
self->error =
autoar_common_g_error_new_a (a, self->source_basename);
self->error = g_error_new_literal (AUTOAR_EXTRACTOR_ERROR,
EMPTY_ARCHIVE_ERRNO,
"empty archive");
}
archive_read_free (a);
return;
......@@ -1877,8 +1877,7 @@ autoar_extractor_step_extract (AutoarExtractor *self) {
r = libarchive_create_read_object (self->use_raw_format, self, &a);
if (r != ARCHIVE_OK) {
if (self->error == NULL) {
self->error =
autoar_common_g_error_new_a (a, self->source_basename);
self->error = autoar_common_g_error_new_a (a, NULL);
}
archive_read_free (a);
return;
......@@ -1999,8 +1998,7 @@ autoar_extractor_step_extract (AutoarExtractor *self) {
if (r != ARCHIVE_EOF) {
if (self->error == NULL) {
self->error =
autoar_common_g_error_new_a (a, self->source_basename);
self->error = autoar_common_g_error_new_a (a, NULL);
}
archive_read_free (a);
return;
......
......@@ -3,7 +3,7 @@
project(
'gnome-autoar', 'c',
version: '0.4.2',
version: '0.4.3',
license: 'LGPL2.1+',
default_options: 'buildtype=debugoptimized',
meson_version: '>= 0.56.0',
......