After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735120 - Segfault with truncated file
Segfault with truncated file
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: archive backend
1.21.x
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2014-08-20 19:48 UTC by Ross Lagerwall
Modified: 2014-08-23 07:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test archive (439.45 KB, application/gzip)
2014-08-20 19:48 UTC, Ross Lagerwall
  Details
archive: Retry operations that return ARCHIVE_RETRY (2.34 KB, patch)
2014-08-20 19:52 UTC, Ross Lagerwall
needs-work Details | Review
archive: Retry operations that return ARCHIVE_RETRY (2.15 KB, patch)
2014-08-22 07:09 UTC, Ross Lagerwall
committed Details | Review

Description Ross Lagerwall 2014-08-20 19:48:07 UTC
Created attachment 283999 [details]
Test archive

The archive backend segfaults with the attached (truncated) file.
Comment 1 Ross Lagerwall 2014-08-20 19:52:07 UTC
Created attachment 284000 [details] [review]
archive: Retry operations that return ARCHIVE_RETRY

Retry operations that return ARCHIVE_RETRY since it indicates that the
operation has failed, the archive_entry is not valid, and the operation
should be retried to see if it succeeds.

This fixes a segfault on a truncated archive where
archive_read_next_header would return ARCHIVE_RETRY and the backend
would continue to try and use the invalid archive_entry that was
returned.
Comment 2 Ondrej Holy 2014-08-21 12:42:21 UTC
Review of attachment 284000 [details] [review]:

It would be good to clear the error before retrying...

if (result < ARCHIVE_OK) {
    DEBUG ("archive_read_data_block: result = %d, error = '%s'\n", result, archive_error_string (archive->archive));
    archive_set_error (archive->archive, ARCHIVE_OK, "No error");
    archive_clear_error (archive->archive);
}
if (result == ARCHIVE_RETRY)
    continue;
Comment 3 Ross Lagerwall 2014-08-22 07:09:00 UTC
Created attachment 284166 [details] [review]
archive: Retry operations that return ARCHIVE_RETRY

Retry operations that return ARCHIVE_RETRY since it indicates that the
operation has failed, the archive_entry is not valid, and the operation
should be retried to see if it succeeds.

This fixes a segfault on a truncated archive where
archive_read_next_header would return ARCHIVE_RETRY and the backend
would continue to try and use the invalid archive_entry that was
returned.
Comment 4 Ondrej Holy 2014-08-22 08:47:45 UTC
Review of attachment 284166 [details] [review]:

Looks good, thanks!
Comment 5 Ross Lagerwall 2014-08-23 07:29:29 UTC
Pushed to master and gnome-3-12. Thanks for the reviews!