diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2016-03-09 18:05:06 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2016-03-09 18:05:44 +0100 |
commit | 616e77a54964aee8754acefbea4e76a15529dfa7 (patch) | |
tree | 27818418b7b1cf85c4636b62c2189e83e7f22b32 | |
parent | 53548febd5b13de8b46fbe87762cc5e1b3c70b63 (diff) | |
download | gcab-616e77a54964aee8754acefbea4e76a15529dfa7.tar.gz |
extract: learn to rewind if needed
In some cases, files my point to previously treated offset. Let's rewind
in this case.
https://bugzilla.gnome.org/show_bug.cgi?id=763377
-rw-r--r-- | libgcab/gcab-folder.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libgcab/gcab-folder.c b/libgcab/gcab-folder.c index da14044..e724097 100644 --- a/libgcab/gcab-folder.c +++ b/libgcab/gcab-folder.c @@ -404,6 +404,16 @@ gcab_folder_extract (GCabFolder *self, u4 usize = file->cfile.usize; u4 uoffset = file->cfile.uoffset; + + /* let's rewind if need be */ + if (uoffset < nubytes) { + if (!g_seekable_seek (G_SEEKABLE (data), self->cfolder.offsetdata, + G_SEEK_SET, cancellable, error)) + goto end; + bzero(&cdata, sizeof(cdata)); + nubytes = 0; + } + while (usize > 0) { if ((nubytes + cdata.nubytes) <= uoffset) { nubytes += cdata.nubytes; |