From 2af17490a08c29b033942da42d27b5bda076ad05 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 26 Apr 2022 12:03:53 +0200 Subject: [PATCH] Bug fix: The lseek methods of IsoFileSource for local filesystem and loaded ISO returned libisofs error codes as positive off_t numbers --- libisofs/fs_image.c | 10 +++++----- libisofs/fs_local.c | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 6a40e06..293a7c9 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -961,18 +961,18 @@ off_t ifs_lseek(IsoFileSource *src, off_t offset, int flag) ImageFileSourceData *data; if (src == NULL) { - return (off_t)ISO_NULL_POINTER; + return (off_t)((int) ISO_NULL_POINTER); } if (offset < (off_t)0) { - return (off_t)ISO_WRONG_ARG_VALUE; + return (off_t)((int) ISO_WRONG_ARG_VALUE); } data = src->data; if (!data->opened) { - return (off_t)ISO_FILE_NOT_OPENED; + return (off_t)((int) ISO_FILE_NOT_OPENED); } else if (data->opened != 1) { - return (off_t)ISO_FILE_IS_DIR; + return (off_t)((int) ISO_FILE_IS_DIR); } switch (flag) { @@ -987,7 +987,7 @@ off_t ifs_lseek(IsoFileSource *src, off_t offset, int flag) data->data.offset = data->info.st_size + offset; break; default: - return (off_t)ISO_WRONG_ARG_VALUE; + return (off_t)((int) ISO_WRONG_ARG_VALUE); } /* diff --git a/libisofs/fs_local.c b/libisofs/fs_local.c index 68462d4..094b4cb 100644 --- a/libisofs/fs_local.c +++ b/libisofs/fs_local.c @@ -337,7 +337,7 @@ off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag) int whence; if (src == NULL) { - return (off_t)ISO_NULL_POINTER; + return (off_t)((int) ISO_NULL_POINTER); } switch (flag) { case 0: @@ -347,7 +347,7 @@ off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag) case 2: whence = SEEK_END; break; default: - return (off_t)ISO_WRONG_ARG_VALUE; + return (off_t)((int) ISO_WRONG_ARG_VALUE); } data = src->data; @@ -360,19 +360,19 @@ off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag) /* error on read */ switch (errno) { case ESPIPE: - ret = (off_t)ISO_FILE_ERROR; + ret = (off_t)((int) ISO_FILE_ERROR); break; default: - ret = (off_t)ISO_ERROR; + ret = (off_t)((int) ISO_ERROR); break; } } return ret; } case 2: /* directory */ - return (off_t)ISO_FILE_IS_DIR; + return (off_t)((int) ISO_FILE_IS_DIR); default: - return (off_t)ISO_FILE_NOT_OPENED; + return (off_t)((int) ISO_FILE_NOT_OPENED); } }