"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Common/libzip/zip_source_seek.c" between
VeraCrypt_1.21_Source.tar.bz2 and VeraCrypt_1.22_Source.tar.bz2

About: VeraCrypt is a free disk encryption software (based on TrueCrypt).

zip_source_seek.c  (VeraCrypt_1.21_Source.tar.bz2):zip_source_seek.c  (VeraCrypt_1.22_Source.tar.bz2)
skipping to change at line 37 skipping to change at line 37
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "zipint.h" #include "zipint.h"
ZIP_EXTERN int ZIP_EXTERN int
zip_source_seek(zip_source_t *src, zip_int64_t offset, int whence) zip_source_seek(zip_source_t *src, zip_int64_t offset, int whence) {
{
zip_source_args_seek_t args; zip_source_args_seek_t args;
if (src->source_closed) { if (src->source_closed) {
return -1; return -1;
} }
if (!ZIP_SOURCE_IS_OPEN_READING(src) || (whence != SEEK_SET && whence != SEE K_CUR && whence != SEEK_END)) { if (!ZIP_SOURCE_IS_OPEN_READING(src) || (whence != SEEK_SET && whence != SEE K_CUR && whence != SEEK_END)) {
zip_error_set(&src->error, ZIP_ER_INVAL, 0); zip_error_set(&src->error, ZIP_ER_INVAL, 0);
return -1; return -1;
} }
args.offset = offset; args.offset = offset;
args.whence = whence; args.whence = whence;
return (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0 ? -1 : 0); return (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0 ? -1 : 0);
} }
zip_int64_t zip_int64_t
zip_source_seek_compute_offset(zip_uint64_t offset, zip_uint64_t length, void *d zip_source_seek_compute_offset(zip_uint64_t offset, zip_uint64_t length, void *d
ata, zip_uint64_t data_length, zip_error_t *error) ata, zip_uint64_t data_length, zip_error_t *error) {
{
zip_int64_t new_offset; zip_int64_t new_offset;
zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, d ata, data_length, error); zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, d ata, data_length, error);
if (args == NULL) { if (args == NULL) {
return -1; return -1;
} }
switch (args->whence) { switch (args->whence) {
case SEEK_CUR: case SEEK_CUR:
new_offset = (zip_int64_t)offset + args->offset; new_offset = (zip_int64_t)offset + args->offset;
break; break;
case SEEK_END: case SEEK_END:
new_offset = (zip_int64_t)length + args->offset; new_offset = (zip_int64_t)length + args->offset;
break; break;
case SEEK_SET: case SEEK_SET:
new_offset = args->offset; new_offset = args->offset;
break; break;
default: default:
zip_error_set(error, ZIP_ER_INVAL, 0); zip_error_set(error, ZIP_ER_INVAL, 0);
return -1; return -1;
} }
if (new_offset < 0 || (zip_uint64_t)new_offset > length) { if (new_offset < 0 || (zip_uint64_t)new_offset > length) {
zip_error_set(error, ZIP_ER_INVAL, 0); zip_error_set(error, ZIP_ER_INVAL, 0);
return -1; return -1;
} }
return new_offset; return new_offset;
} }
 End of changes. 7 change blocks. 
26 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)