~ubuntu-branches/ubuntu/vivid/libzip/vivid

« back to all changes in this revision

Viewing changes to lib/zip_file_get_offset.c

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2014-02-09 13:24:18 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140209132418-t7u2auujqnfb5rvm
Tags: 0.11.2-1
* New upstream release (Closes: #734388).
* Remove patches:
  - fix_open_nonarchive_test.patch - fixed upstream
  - fix_zipconf_path.patch - fixed upstream
  - fix_broken_decrypt.patch - fixed upstream
  - fix_autotools_tests.diff - stolen upstream
* Update debian/control:
  - add unzip to Build-Depends.
  - bump compat to 9
* Update *.install: multiarch paths.
* Update libzip2 symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
   On error, fills in za->error and returns 0.
51
51
*/
52
52
 
53
 
unsigned int
54
 
_zip_file_get_offset(struct zip *za, int idx)
 
53
zip_uint64_t
 
54
_zip_file_get_offset(const struct zip *za, zip_uint64_t idx, struct zip_error *error)
55
55
{
56
 
    struct zip_dirent de;
57
 
    unsigned int offset;
58
 
 
59
 
    offset = za->cdir->entry[idx].offset;
60
 
 
61
 
    if (fseeko(za->zp, offset, SEEK_SET) != 0) {
62
 
        _zip_error_set(&za->error, ZIP_ER_SEEK, errno);
63
 
        return 0;
64
 
    }
65
 
 
66
 
    if (_zip_dirent_read(&de, za->zp, NULL, NULL, 1, &za->error) != 0)
67
 
        return 0;
68
 
 
69
 
    offset += LENTRYSIZE + de.filename_len + de.extrafield_len;
70
 
 
71
 
    _zip_dirent_finalize(&de);
72
 
 
73
 
    return offset;
 
56
    zip_uint64_t offset;
 
57
    zip_int32_t size;
 
58
 
 
59
    offset = za->entry[idx].orig->offset;
 
60
 
 
61
    if (fseeko(za->zp, (off_t)offset, SEEK_SET) != 0) {
 
62
        _zip_error_set(error, ZIP_ER_SEEK, errno);
 
63
        return 0;
 
64
    }
 
65
 
 
66
    /* TODO: cache? */
 
67
    if ((size=_zip_dirent_size(za->zp, ZIP_EF_LOCAL, error)) < 0)
 
68
        return 0;
 
69
 
 
70
    if (offset+(zip_uint32_t)size > ZIP_OFF_MAX) {
 
71
        _zip_error_set(error, ZIP_ER_SEEK, EFBIG);
 
72
        return 0;
 
73
    }
 
74
    
 
75
    return offset + (zip_uint32_t)size;
74
76
}