From 97b4e623cdb84522868c8cfdd6ce1f1a102d68b1 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 9 Mar 2017 15:34:37 +0100 Subject: [PATCH] [iso] update libcdio to latest * Also update .gitignore for VS2017 files --- .gitignore | 5 + src/libcdio/cdio/bytesex.h | 24 +- src/libcdio/cdio/types.h | 91 +++--- src/libcdio/cdio/version.h | 9 +- src/libcdio/config.h | 4 +- src/libcdio/driver/.clang/driver.vcxproj | 2 +- .../driver/.clang/driver.vcxproj.filters | 2 +- src/libcdio/driver/.msvc/driver.vcxproj | 2 +- .../driver/.msvc/driver.vcxproj.filters | 2 +- src/libcdio/driver/_cdio_stdio.c | 33 +-- src/libcdio/driver/_cdio_stream.c | 35 ++- src/libcdio/driver/cdio_private.h | 258 ++++++++++-------- src/libcdio/driver/ds.c | 28 +- src/libcdio/driver/logging.c | 25 +- src/libcdio/driver/memory.c | 7 +- src/libcdio/{cdio => driver}/portable.h | 0 src/libcdio/driver/sector.c | 7 +- src/libcdio/iso9660/iso9660.c | 9 +- src/libcdio/iso9660/iso9660_fs.c | 67 +++-- src/libcdio/iso9660/rock.c | 21 +- src/libcdio/mmc/mmc_private.h | 3 + src/libcdio/udf/udf_fs.c | 8 +- src/rufus.rc | 10 +- 23 files changed, 372 insertions(+), 280 deletions(-) rename src/libcdio/{cdio => driver}/portable.h (100%) create mode 100644 src/libcdio/mmc/mmc_private.h diff --git a/.gitignore b/.gitignore index 8f38e494..680daafc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ *.a *.aps +*.db +*.db-shm +*.db-wal *.dep *.exe *.htm *.idb +*.ipch *.la *.lib *.lo @@ -12,6 +16,7 @@ *.ncb *.o *.obj +*.opendb *.opt *.pc *.pdb diff --git a/src/libcdio/cdio/bytesex.h b/src/libcdio/cdio/bytesex.h index 696fbd41..0ec92463 100644 --- a/src/libcdio/cdio/bytesex.h +++ b/src/libcdio/cdio/bytesex.h @@ -1,6 +1,6 @@ /* Copyright (C) 2000, 2004 Herbert Valerio Riedel - Copyright (C) 2005, 2008, 2012 Rocky Bernstein + Copyright (C) 2005, 2008, 2012, 2015 Rocky Bernstein This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ along with this program. If not, see . */ -/** \file bytesex.h +/** \file bytesex.h * \brief Generic Byte-swapping routines. * * Note: this header will is slated to get removed and libcdio will @@ -168,7 +168,7 @@ to_723(uint16_t i) } /** Convert from ISO 9660 7.2.3 format to uint16_t */ -static CDIO_INLINE uint16_t +static CDIO_INLINE uint16_t from_723 (uint32_t p) { if (uint32_swap_le_be (p) != p) @@ -197,19 +197,31 @@ to_733(uint32_t i) } /** Convert from ISO 9660 7.3.3 format to uint32_t */ -static CDIO_INLINE uint32_t +static CDIO_INLINE uint32_t from_733 (uint64_t p) { if (uint64_swap_le_be (p) != p) cdio_warn ("from_733: broken byte order"); - + + return (UINT32_C(0xFFFFFFFF) & p); +} + +static CDIO_INLINE uint32_t +from_733_with_err (uint64_t p, bool *err) +{ + if (uint64_swap_le_be (p) != p) { + cdio_warn ("from_733: broken byte order"); + *err = true; + } else { + *err = false; + } return (UINT32_C(0xFFFFFFFF) & p); } #endif /* CDIO_BYTESEX_H_ */ -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/libcdio/cdio/types.h b/src/libcdio/cdio/types.h index 12917503..3274b61f 100644 --- a/src/libcdio/cdio/types.h +++ b/src/libcdio/cdio/types.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -/** \file types.h +/** \file types.h * \brief Common type definitions used pervasively in libcdio. */ @@ -31,9 +31,9 @@ extern "C" { /* If is not available on your platform please contact the libcdio mailing list so that we can fix it! */ -#if !defined(ARE_THERE_STILL_ENVS_WITHOUT_SYS_TYPES) +#if !defined(ARE_THERE_STILL_ENVS_WITHOUT_SYS_TYPES) #include -#endif +#endif #if defined(AMIGA) typedef u_int8_t uint8_t; @@ -68,11 +68,11 @@ typedef uint8_t ubyte; /* if it's still not defined, take a good guess... should work for most 32bit and 64bit archs */ - + #ifndef UINT16_C # define UINT16_C(c) c ## U #endif - + #ifndef UINT32_C # if defined (SIZEOF_INT) && SIZEOF_INT == 4 # define UINT32_C(c) c ## U @@ -82,7 +82,7 @@ typedef uint8_t ubyte; # define UINT32_C(c) c ## U # endif #endif - + #ifndef UINT64_C # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8 # define UINT64_C(c) c ## UL @@ -92,17 +92,17 @@ typedef uint8_t ubyte; # define UINT64_C(c) c ## ULL # endif #endif - + #ifndef INT64_C # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8 # define INT64_C(c) c ## L # elif defined (SIZEOF_INT) && SIZEOF_INT == 8 -# define INT64_C(c) c +# define INT64_C(c) c # else # define INT64_C(c) c ## LL # endif #endif - + #ifndef __cplusplus /* All the stdbool.h seem to define those */ @@ -123,10 +123,10 @@ typedef uint8_t ubyte; #endif /* __bool_true_false_are_defined */ #endif /*C++*/ - + /* some GCC optimizations -- gcc 2.5+ */ - -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) || __clang__ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) #define GNUC_PRINTF( format_idx, arg_idx ) \ __attribute__((format (printf, format_idx, arg_idx))) #define GNUC_SCANF( format_idx, arg_idx ) \ @@ -150,13 +150,14 @@ typedef uint8_t ubyte; #define GNUC_UNUSED #define GNUC_PACKED #endif /* !__GNUC__ */ - + #if defined(__MINGW32__) # define PRAGMA_BEGIN_PACKED _Pragma("pack(push)") \ _Pragma("pack(1)") # define PRAGMA_END_PACKED _Pragma("pack(pop)") -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) - /* should work with most EDG-frontend based compilers */ +#elif __GNUC__ > 4 || (__STDC_VERSION__ >= 199901) + /* should work with GCC > 4.0 clang and most EDG-frontend based C + and C++ compilers */ # define PRAGMA_BEGIN_PACKED _Pragma("pack(1)") # define PRAGMA_END_PACKED _Pragma("pack()") #elif defined(_MSC_VER) @@ -167,18 +168,18 @@ typedef uint8_t ubyte; # define PRAGMA_BEGIN_PACKED # define PRAGMA_END_PACKED #endif - + /* * user directed static branch prediction gcc 2.96+ */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95) # define GNUC_LIKELY(x) __builtin_expect((x),true) # define GNUC_UNLIKELY(x) __builtin_expect((x),false) -#else -# define GNUC_LIKELY(x) (x) +#else +# define GNUC_LIKELY(x) (x) # define GNUC_UNLIKELY(x) (x) #endif - + #ifndef NULL # define NULL ((void*) 0) #endif @@ -199,9 +200,9 @@ typedef uint8_t ubyte; /** our own offsetof()-like macro */ #define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - + /*! - \brief MSF (minute/second/frame) structure + \brief MSF (minute/second/frame) structure One CD-ROMs addressing scheme especially used in audio formats (Red Book) is an address by minute, sector and frame which @@ -211,7 +212,7 @@ typedef uint8_t ubyte; cdio_to_bcd8() or cdio_from_bcd8() to convert an integer into or out of this format. The format specifier %x (not %d) can be used if you need to format or print values in this structure. - + @see lba_t */ PRAGMA_BEGIN_PACKED @@ -219,13 +220,13 @@ typedef uint8_t ubyte; uint8_t m, s, f; /* BCD encoded! */ } GNUC_PACKED; PRAGMA_END_PACKED - + typedef struct msf_s msf_t; #define msf_t_SIZEOF 3 /*! - \brief UTF-8 char definition + \brief UTF-8 char definition Type to denote UTF-8 strings. */ @@ -237,7 +238,7 @@ typedef uint8_t ubyte; yep = 1, dunno = 2 } bool_3way_t; - + /* type used for bit-fields in structs (1 <= bits <= 8) */ #if defined(__GNUC__) /* this is strict ISO C99 which allows only 'unsigned int', 'signed @@ -249,23 +250,23 @@ typedef uint8_t ubyte; be pragma'ed on non-gcc compilers */ typedef uint8_t bitfield_t; #endif - - /*! The type of a Logical Block Address. We allow for an lba to be + + /*! The type of a Logical Block Address. We allow for an lba to be negative to be consistent with an lba, although I'm not sure this this is possible. - + */ typedef int32_t lba_t; - + /*! The type of a Logical Sector Number. Note that an lba can be negative and the MMC3 specs allow for a conversion of a negative lba. @see msf_t */ typedef int32_t lsn_t; - + /* Address in either MSF or logical format */ - union cdio_cdrom_addr + union cdio_cdrom_addr { msf_t msf; lba_t lba; @@ -273,46 +274,46 @@ typedef uint8_t ubyte; /*! The type of a track number 0..99. */ typedef uint8_t track_t; - + /*! The type of a session number 0..99. */ typedef uint8_t session_t; - - /*! + + /*! Constant for invalid session number */ #define CDIO_INVALID_SESSION 0xFF - - /*! + + /*! Constant for invalid LBA. It is 151 less than the most negative LBA -45150. This provide slack for the 150-frame offset in LBA to LSN 150 conversions */ #define CDIO_INVALID_LBA -45301 - - /*! + + /*! Constant for invalid LSN */ #define CDIO_INVALID_LSN CDIO_INVALID_LBA - /*! + /*! Number of ASCII bytes in a media catalog number (MCN). We include an extra 0 byte so these can be used as C strings. */ #define CDIO_MCN_SIZE 13 - /*! + /*! Type to hold ASCII bytes in a media catalog number (MCN). We include an extra 0 byte so these can be used as C strings. */ typedef char cdio_mcn_t[CDIO_MCN_SIZE+1]; - - /*! + + /*! Number of ASCII bytes in International Standard Recording Codes (ISRC) */ #define CDIO_ISRC_SIZE 12 - /*! + /*! Type to hold ASCII bytes in a ISRC. We include an extra 0 byte so these can be used as C strings. */ @@ -320,7 +321,7 @@ typedef uint8_t ubyte; typedef int cdio_fs_anal_t; - /*! + /*! track flags Q Sub-channel Control Field (4.2.3.3) */ @@ -341,7 +342,7 @@ typedef uint8_t ubyte; #endif /* CDIO_TYPES_H_ */ -/* +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/libcdio/cdio/version.h b/src/libcdio/cdio/version.h index c1891525..b0e5d4fe 100644 --- a/src/libcdio/cdio/version.h +++ b/src/libcdio/cdio/version.h @@ -1,20 +1,19 @@ -/* $Id: version.h.in,v 1.6 2005/01/29 20:54:20 rocky Exp $ */ -/** \file version.h +/** \file version.h * * \brief A file containing the libcdio package version - * number (90) and OS build name. + * number (94) and OS build name. */ /*! CDIO_VERSION is a C-Preprocessor macro of a string that shows what version is used. cdio_version_string has the same value, but it is a constant variable that can be accessed at run time. */ -#define CDIO_VERSION "0.93 i686-pc-mingw32" +#define CDIO_VERSION "0.94 i686-w64-mingw32" extern const char *cdio_version_string; /**< = CDIO_VERSION */ /*! LIBCDIO_VERSION_NUM is a C-Preprocessor macro that can be used for testing in the C preprocessor. libcdio_version_num has the same value, but it is a constant variable that can be accessed at run time. */ -#define LIBCDIO_VERSION_NUM 93 +#define LIBCDIO_VERSION_NUM 94 extern const unsigned int libcdio_version_num; /**< = LIBCDIO_VERSION_NUM */ diff --git a/src/libcdio/config.h b/src/libcdio/config.h index 0aacce4a..97675cd5 100644 --- a/src/libcdio/config.h +++ b/src/libcdio/config.h @@ -134,7 +134,9 @@ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strndup' function. */ -/* #undef HAVE_STRNDUP */ +#if defined(__MINGW32__) +#define HAVE_STRNDUP 1 +#endif /* Define this if you have struct timespec */ /* #undef HAVE_STRUCT_TIMESPEC */ diff --git a/src/libcdio/driver/.clang/driver.vcxproj b/src/libcdio/driver/.clang/driver.vcxproj index a605de51..92649543 100644 --- a/src/libcdio/driver/.clang/driver.vcxproj +++ b/src/libcdio/driver/.clang/driver.vcxproj @@ -36,7 +36,6 @@ - @@ -45,6 +44,7 @@ + diff --git a/src/libcdio/driver/.clang/driver.vcxproj.filters b/src/libcdio/driver/.clang/driver.vcxproj.filters index 13592e79..de927206 100644 --- a/src/libcdio/driver/.clang/driver.vcxproj.filters +++ b/src/libcdio/driver/.clang/driver.vcxproj.filters @@ -88,7 +88,7 @@ Header Files - + Header Files diff --git a/src/libcdio/driver/.msvc/driver.vcxproj b/src/libcdio/driver/.msvc/driver.vcxproj index e96ae95a..40c61f7a 100644 --- a/src/libcdio/driver/.msvc/driver.vcxproj +++ b/src/libcdio/driver/.msvc/driver.vcxproj @@ -36,7 +36,6 @@ - @@ -45,6 +44,7 @@ + diff --git a/src/libcdio/driver/.msvc/driver.vcxproj.filters b/src/libcdio/driver/.msvc/driver.vcxproj.filters index 13592e79..de927206 100644 --- a/src/libcdio/driver/.msvc/driver.vcxproj.filters +++ b/src/libcdio/driver/.msvc/driver.vcxproj.filters @@ -88,7 +88,7 @@ Header Files - + Header Files diff --git a/src/libcdio/driver/_cdio_stdio.c b/src/libcdio/driver/_cdio_stdio.c index 5340b11e..805cc699 100644 --- a/src/libcdio/driver/_cdio_stdio.c +++ b/src/libcdio/driver/_cdio_stdio.c @@ -31,7 +31,7 @@ #include #endif #ifdef HAVE_UNISTD_H -#include +#include #endif #ifdef HAVE_SYS_STAT_H #include @@ -88,8 +88,6 @@ static inline int _stati64_utf8(const char *path, struct _stati64 *buffer) { #define _STRINGIFY(a) #a #define STRINGIFY(a) _STRINGIFY(a) -// static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.6 2008/04/22 15:29:11 karl Exp $"; - #define CDIO_STDIO_BUFSIZE (128*1024) typedef struct { @@ -100,7 +98,7 @@ typedef struct { } _UserData; static int -_stdio_open (void *user_data) +_stdio_open (void *user_data) { _UserData *const ud = user_data; @@ -120,7 +118,7 @@ _stdio_close(void *user_data) if (fclose (ud->fd)) cdio_error ("fclose (): %s", strerror (errno)); - + ud->fd = NULL; free (ud->fd_buf); @@ -138,14 +136,14 @@ _stdio_free(void *user_data) free(ud->pathname); if (ud->fd) /* should be NULL anyway... */ - _stdio_close(user_data); + _stdio_close(user_data); free(ud); } -/*! +/*! Like fseek/fseeko(3) and in fact may be the same. - + This function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence @@ -154,12 +152,12 @@ _stdio_free(void *user_data) respectively. A successful call to the fseek function clears the end- of-file indicator for the stream and undoes any effects of the ungetc(3) function on the same stream. - + @return upon successful completion, DRIVER_OP_SUCCESS, else, DRIVER_OP_ERROR is returned and the global variable errno is set to indicate the error. */ -static int +static int _stdio_seek(void *p_user_data, off_t i_offset, int whence) { _UserData *const ud = p_user_data; @@ -190,18 +188,18 @@ _stdio_stat(void *p_user_data) /*! Like fread(3) and in fact is about the same. - + DESCRIPTION: The function fread reads nmemb elements of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr. - + RETURN VALUE: return the number of items successfully read or written (i.e., not the number of characters). If an error occurs, or the end-of-file is reached, the return value is a short item count (or zero). - + We do not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred. */ @@ -258,9 +256,9 @@ cdio_stdio_new(const char pathname[]) if (pathdup == NULL) return NULL; - if (CDIO_STAT_CALL (pathdup, &statbuf) == -1) + if (CDIO_STAT_CALL (pathdup, &statbuf) == -1) { - cdio_warn ("could not retrieve file info for `%s': %s", + cdio_warn ("could not retrieve file info for `%s': %s", pathdup, strerror (errno)); cdio_free(pathdup); return NULL; @@ -283,9 +281,8 @@ cdio_stdio_new(const char pathname[]) return new_obj; } - - -/* + +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/libcdio/driver/_cdio_stream.c b/src/libcdio/driver/_cdio_stream.c index dd36378d..79dab947 100644 --- a/src/libcdio/driver/_cdio_stream.c +++ b/src/libcdio/driver/_cdio_stream.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2005, 2006, 2008, 2011 Rocky Bernstein + Copyright (C) 2005, 2006, 2008, 2011, 2016 Rocky Bernstein Copyright (C) 2000, 2004, 2005 Herbert Valerio Riedel This program is free software: you can redistribute it and/or modify @@ -41,9 +41,7 @@ #include #include "_cdio_stream.h" -// static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.9 2008/04/22 15:29:11 karl Exp $"; - -/* +/* * DataSource implementations */ @@ -81,10 +79,10 @@ cdio_stream_destroy(CdioDataSource_t *p_obj) /** Like 3 fgetpos. - + This function gets the current file position indicator for the stream - pointed to by stream. - + pointed to by stream. + @return unpon successful completion, return value is positive, else, the global variable errno is set to indicate the error. */ @@ -108,8 +106,8 @@ cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs) return new_obj; } -/* - Open if not already open. +/* + Open if not already open. Return false if we hit an error. Errno should be set for that error. */ static bool @@ -132,18 +130,18 @@ _cdio_stream_open_if_necessary(CdioDataSource_t *p_obj) /** Like fread(3) and in fact may be the same. - + DESCRIPTION: The function fread reads nmemb elements of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr. - + RETURN VALUE: return the number of items successfully read or written (i.e., not the number of characters). If an error occurs, or the end-of-file is reached, the return value is a short item count (or zero). - + We do not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred. */ @@ -163,7 +161,7 @@ cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, size_t size, size_t nmemb) /** Like 3 fseek and in fact may be the same. - + This function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence @@ -172,7 +170,7 @@ cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, size_t size, size_t nmemb) respectively. A successful call to the fseek function clears the end- of-file indicator for the stream and undoes any effects of the ungetc(3) function on the same stream. - + @return unpon successful completion, return value is positive, else, the global variable errno is set to indicate the error. */ @@ -181,7 +179,7 @@ cdio_stream_seek(CdioDataSource_t* p_obj, off_t offset, int whence) { if (!p_obj) return DRIVER_OP_UNINIT; - if (!_cdio_stream_open_if_necessary(p_obj)) + if (!_cdio_stream_open_if_necessary(p_obj)) /* errno is set by _cdio_stream_open_if necessary. */ return DRIVER_OP_ERROR; @@ -200,7 +198,7 @@ cdio_stream_seek(CdioDataSource_t* p_obj, off_t offset, int whence) } /** - Return whatever size of stream reports, I guess unit size is bytes. + Return whatever size of stream reports, I guess unit size is bytes. On error return -1; */ off_t @@ -212,9 +210,8 @@ cdio_stream_stat(CdioDataSource_t *p_obj) return p_obj->op.stat(p_obj->user_data); } - - -/* + +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 diff --git a/src/libcdio/driver/cdio_private.h b/src/libcdio/driver/cdio_private.h index dca83567..2fa0d72d 100644 --- a/src/libcdio/driver/cdio_private.h +++ b/src/libcdio/driver/cdio_private.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003, 2004, 2005, 2008, 2009, 2011, 2012 + Copyright (C) 2003-2005, 2008-2009, 2011-2012, 2016 Rocky Bernstein This program is free software: you can redistribute it and/or modify @@ -26,15 +26,37 @@ # include "config.h" #endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + #include #include #include -//#include "mmc/mmc_private.h" +#include "mmc/mmc_private.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#ifndef HAVE_STRNDUP +static inline char *strndup(const char *s, size_t n) +{ + char *result; + size_t len = strlen (s); + if (n < len) + len = n; + result = (char *) malloc (len + 1); + if (!result) + return 0; + result[len] = '\0'; + return (char *) strncpy (result, s, len); +} +#endif /*HAVE_STRNDUP*/ + /*! Get directory name from file name. @@ -65,101 +87,101 @@ extern "C" { typedef struct { - + /*! Get volume of an audio CD. - + @param p_env the CD object to be acted upon. - + */ - driver_return_code_t (*audio_get_volume) + driver_return_code_t (*audio_get_volume) (void *p_env, /*out*/ cdio_audio_volume_t *p_volume); /*! Pause playing CD through analog output - + @param p_env the CD object to be acted upon. */ driver_return_code_t (*audio_pause) (void *p_env); - + /*! Playing CD through analog output - + @param p_env the CD object to be acted upon. */ - driver_return_code_t (*audio_play_msf) ( void *p_env, + driver_return_code_t (*audio_play_msf) ( void *p_env, msf_t *p_start_msf, msf_t *p_end_msf ); /*! Playing CD through analog output - + @param p_env the CD object to be acted upon. */ - driver_return_code_t (*audio_play_track_index) + driver_return_code_t (*audio_play_track_index) ( void *p_env, cdio_track_index_t *p_track_index ); /*! Get subchannel information. - + @param p_env the CD object to be acted upon. */ - driver_return_code_t (*audio_read_subchannel) + driver_return_code_t (*audio_read_subchannel) ( void *p_env, cdio_subchannel_t *subchannel ); /*! Resume playing an audio CD. - + @param p_env the CD object to be acted upon. - + */ driver_return_code_t (*audio_resume) ( void *p_env ); - + /*! Set volume of an audio CD. - + @param p_env the CD object to be acted upon. - + */ - driver_return_code_t (*audio_set_volume) + driver_return_code_t (*audio_set_volume) ( void *p_env, cdio_audio_volume_t *p_volume ); /*! Stop playing an audio CD. - + @param p_env the CD object to be acted upon. - + */ driver_return_code_t (*audio_stop) ( void *p_env ); - + /*! - Eject media in CD drive. If successful, as a side effect we - also free p_env. + Eject media in CD drive. If successful, as a side effect we + also free p_env. @param p_env the CD object to be acted upon. If the CD is ejected *p_env is freed and p_env set to NULL. */ driver_return_code_t (*eject_media) ( void *p_env ); - + /*! - Release and free resources associated with cd. + Release and free resources associated with cd. */ void (*free) (void *p_env); - + /*! Return the value associated with the key "arg". */ const char * (*get_arg) (void *p_env, const char key[]); - + /*! - Get the block size for subsequest read requests, via a SCSI MMC + Get the block size for subsequest read requests, via a SCSI MMC MODE_SENSE 6 command. */ int (*get_blocksize) ( void *p_env ); - - /*! + + /*! Get cdtext information for a CdIo object. - + @param obj the CD object that may contain CD-TEXT information. @return the CD-TEXT object or NULL if obj is NULL or CD-TEXT information does not exist. @@ -176,16 +198,16 @@ extern "C" { free when done and not NULL. */ uint8_t * (*get_cdtext_raw) ( void *p_env ); - + /*! Return an array of device names. if CdIo is NULL (we haven't - initialized a specific device driver), then find a suitable device + initialized a specific device driver), then find a suitable device driver. - + NULL is returned if we couldn't return a list of devices. */ char ** (*get_devices) ( void ); - + /*! Get the default CD device. @@ -197,21 +219,21 @@ extern "C" { NULL even though there may be a hardware CD-ROM. */ char * (*get_default_device) ( void ); - + /*! Return the size of the CD in logical block address (LBA) units. @return the lsn. On error 0 or CDIO_INVALD_LSN. */ lsn_t (*get_disc_last_lsn) ( void *p_env ); - /*! + /*! Get disc mode associated with cd_obj. */ discmode_t (*get_discmode) ( void *p_env ); /*! Return the what kind of device we've got. - + See cd_types.h for a list of bitmasks for the drive type; */ void (*get_drive_cap) (const void *p_env, @@ -219,28 +241,28 @@ extern "C" { cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap); /*! - Return the number of of the first track. + Return the number of of the first track. CDIO_INVALID_TRACK is returned on error. */ track_t (*get_first_track_num) ( void *p_env ); - - /*! + + /*! Get the CD-ROM hardware info via a SCSI MMC INQUIRY command. False is returned if we had an error getting the information. */ - bool (*get_hwinfo) + bool (*get_hwinfo) ( const CdIo_t *p_cdio, /* out*/ cdio_hwinfo_t *p_hw_info ); /*! Get the LSN of the first track of the last session of on the CD. - + @param p_cdio the CD object to be acted upon. @param i_last_session pointer to the session number to be returned. */ driver_return_code_t (*get_last_session) ( void *p_env, /*out*/ lsn_t *i_last_session ); - /*! + /*! Find out if media has changed since the last call. @param p_env the CD object to be acted upon. @return 1 if media has changed since last call, 0 if not. Error @@ -248,31 +270,31 @@ extern "C" { */ int (*get_media_changed) ( const void *p_env ); - /*! + /*! Return the media catalog number MCN from the CD or NULL if there is none or we don't have the ability to get it. */ char * (*get_mcn) ( const void *p_env ); - /*! + /*! Return the number of tracks in the current medium. CDIO_INVALID_TRACK is returned on error. */ track_t (*get_num_tracks) ( void *p_env ); - + /*! Return number of channels in track: 2 or 4; -2 if not implemented or -1 for error. Not meaningful if track is not an audio track. */ int (*get_track_channels) ( const void *p_env, track_t i_track ); - + /*! Return 0 if track is copy protected, 1 if not, or -1 for error or -2 if not implimented (yet). Is this meaningful if not an audio track? */ track_flag_t (*get_track_copy_permit) ( void *p_env, track_t i_track ); - - /*! + + /*! Return the starting LBA for track number i_track in p_env. Tracks numbers start at 1. The "leadout" track is specified either by @@ -281,7 +303,7 @@ extern "C" { */ lba_t (*get_track_lba) ( void *p_env, track_t i_track ); - /*! + /*! Return the starting LBA for the pregap for track number i_track in p_env. Tracks numbers start at 1. CDIO_INVALID_LBA is returned on error. @@ -296,23 +318,23 @@ extern "C" { string when done with it. */ char * (*get_track_isrc) ( const void *p_env, track_t i_track ); - - /*! - Get format of track. + + /*! + Get format of track. */ track_format_t (*get_track_format) ( void *p_env, track_t i_track ); - + /*! Return true if we have XA data (green, mode2 form1) or XA data (green, mode2 form2). That is track begins: sync - header - subheader 12 4 - 8 - + FIXME: there's gotta be a better design for this and get_track_format? */ bool (*get_track_green) ( void *p_env, track_t i_track ); - - /*! + + /*! Return the starting MSF (minutes/secs/frames) for track number i_track in p_env. Tracks numbers start at 1. The "leadout" track is specified either by @@ -320,122 +342,122 @@ extern "C" { False is returned on error. */ bool (*get_track_msf) ( void *p_env, track_t i_track, msf_t *p_msf ); - + /*! Return 1 if track has pre-emphasis, 0 if not, or -1 for error or -2 if not implimented (yet). Is this meaningful if not an audio track? */ - track_flag_t (*get_track_preemphasis) + track_flag_t (*get_track_preemphasis) ( const void *p_env, track_t i_track ); - + /*! lseek - reposition read/write file offset - Returns (off_t) -1 on error. + Returns (off_t) -1 on error. Similar to libc's lseek() */ off_t (*lseek) ( void *p_env, off_t offset, int whence ); - + /*! Reads into buf the next size bytes. - Returns -1 on error. + Returns -1 on error. Similar to libc's read() */ ssize_t (*read) ( void *p_env, void *p_buf, size_t i_size ); - + /*! Reads a single mode2 sector from cd device into buf starting - from lsn. Returns 0 if no error. + from lsn. Returns 0 if no error. */ int (*read_audio_sectors) ( void *p_env, void *p_buf, lsn_t i_lsn, unsigned int i_blocks ); - + /*! Read a data sector - + @param p_env environment to read from @param p_buf place to read data into. The caller should make sure - this location can store at least CDIO_CD_FRAMESIZE, + this location can store at least CDIO_CD_FRAMESIZE, M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending - on the kind of sector getting read. If you don't + on the kind of sector getting read. If you don't know whether you have a Mode 1/2, Form 1/ Form 2/Formless - sector best to reserve space for the maximum, + sector best to reserve space for the maximum, M2RAW_SECTOR_SIZE. @param i_lsn sector to read - @param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE, + @param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE, M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf. */ - driver_return_code_t (*read_data_sectors) + driver_return_code_t (*read_data_sectors) ( void *p_env, void *p_buf, lsn_t i_lsn, uint16_t i_blocksize, uint32_t i_blocks ); - + /*! Reads a single mode2 sector from cd device into buf starting - from lsn. Returns 0 if no error. + from lsn. Returns 0 if no error. */ - int (*read_mode2_sector) + int (*read_mode2_sector) ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2 ); - + /*! Reads i_blocks of mode2 sectors from cd device into data starting from lsn. - Returns 0 if no error. + Returns 0 if no error. */ - int (*read_mode2_sectors) - ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2, + int (*read_mode2_sectors) + ( void *p_env, void *p_buf, lsn_t i_lsn, bool b_mode2_form2, unsigned int i_blocks ); - + /*! Reads a single mode1 sector from cd device into buf starting - from lsn. Returns 0 if no error. + from lsn. Returns 0 if no error. */ - int (*read_mode1_sector) + int (*read_mode1_sector) ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2 ); - + /*! Reads i_blocks of mode1 sectors from cd device into data starting from lsn. - Returns 0 if no error. + Returns 0 if no error. */ - int (*read_mode1_sectors) - ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2, + int (*read_mode1_sectors) + ( void *p_env, void *p_buf, lsn_t i_lsn, bool mode1_form2, unsigned int i_blocks ); - + bool (*read_toc) ( void *p_env ) ; /*! - Run a SCSI MMC command. - + Run a SCSI MMC command. + cdio CD structure set by cdio_open(). i_timeout_ms time in milliseconds we will wait for the command - to complete. + to complete. cdb_len number of bytes in cdb (6, 10, or 12). - cdb CDB bytes. All values that are needed should be set on - input. - b_return_data TRUE if the command expects data to be returned in + cdb CDB bytes. All values that are needed should be set on + input. + b_return_data TRUE if the command expects data to be returned in the buffer len Size of buffer buf Buffer for data, both sending and receiving - + Returns 0 if command completed successfully. */ -// mmc_run_cmd_fn_t run_mmc_cmd; + mmc_run_cmd_fn_t run_mmc_cmd; /*! Set the arg "key" with "value" in the source device. */ int (*set_arg) ( void *p_env, const char key[], const char value[] ); - + /*! - Set the blocksize for subsequent reads. + Set the blocksize for subsequent reads. */ - driver_return_code_t (*set_blocksize) ( void *p_env, + driver_return_code_t (*set_blocksize) ( void *p_env, uint16_t i_blocksize ); /*! - Set the drive speed. - + Set the drive speed. + @return 0 if everything went okay, -1 if we had an error. is -2 returned if this is not implemented for the current driver. */ @@ -452,51 +474,51 @@ extern "C" { void *env; /**< environment. Passed to routine above. */ }; - /* This is used in drivers that must keep their own internal + /* This is used in drivers that must keep their own internal position pointer for doing seeks. Stream-based drivers (like bincue, - nrg, toc, network) would use this. + nrg, toc, network) would use this. */ - typedef struct + typedef struct { off_t buff_offset; /* buffer offset in disk-image seeks. */ track_t index; /* Current track index in tocent. */ lba_t lba; /* Current LBA */ } internal_position_t; - + CdIo_t * cdio_new (generic_img_private_t *p_env, cdio_funcs_t *p_funcs); /* The below structure describes a specific CD Input driver */ - typedef struct + typedef struct { driver_id_t id; unsigned int flags; const char *name; const char *describe; - bool (*have_driver) (void); - CdIo_t *(*driver_open) (const char *psz_source_name); - CdIo_t *(*driver_open_am) (const char *psz_source_name, - const char *psz_access_mode); - char *(*get_default_device) (void); + bool (*have_driver) (void); + CdIo_t *(*driver_open) (const char *psz_source_name); + CdIo_t *(*driver_open_am) (const char *psz_source_name, + const char *psz_access_mode); + char *(*get_default_device) (void); bool (*is_device) (const char *psz_source_name); char **(*get_devices) (void); driver_return_code_t (*close_tray) (const char *psz_device); } CdIo_driver_t; - /* The below array gives of the drivers that are currently available for + /* The below array gives of the drivers that are currently available for on a particular host. */ extern CdIo_driver_t CdIo_driver[]; - /* The last valid entry of Cdio_driver. -1 means uninitialzed. -2 + /* The last valid entry of Cdio_driver. -1 means uninitialzed. -2 means some sort of error. */ - extern int CdIo_last_driver; + extern int CdIo_last_driver; /* The below array gives all drivers that can possibly appear. on a particular host. */ extern CdIo_driver_t CdIo_all_drivers[]; - /*! - Add/allocate a drive to the end of drives. + /*! + Add/allocate a drive to the end of drives. Use cdio_free_device_list() to free this device_list. */ void cdio_add_device_list(char **device_list[], const char *psz_drive, diff --git a/src/libcdio/driver/ds.c b/src/libcdio/driver/ds.c index 28a9aed5..cf53e548 100644 --- a/src/libcdio/driver/ds.c +++ b/src/libcdio/driver/ds.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2005, 2008, 2011 Rocky Bernstein + Copyright (C) 2005, 2008, 2011, 2016 Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel This program is free software: you can redistribute it and/or modify @@ -33,8 +33,6 @@ #include #include "cdio_assert.h" -// static const char _rcsid[] = "$Id: ds.c,v 1.4 2008/04/22 15:29:12 karl Exp $"; - struct _CdioList { unsigned length; @@ -87,7 +85,7 @@ _cdio_list_prepend (CdioList_t *p_list, void *p_data) cdio_assert (p_list != NULL); p_new_node = calloc (1, sizeof (CdioListNode_t)); - + p_new_node->list = p_list; p_new_node->next = p_list->begin; p_new_node->data = p_data; @@ -111,7 +109,7 @@ _cdio_list_append (CdioList_t *p_list, void *p_data) else { CdioListNode_t *p_new_node = calloc (1, sizeof (CdioListNode_t)); - + p_new_node->list = p_list; p_new_node->next = NULL; p_new_node->data = p_data; @@ -123,15 +121,15 @@ _cdio_list_append (CdioList_t *p_list, void *p_data) } } -void -_cdio_list_foreach (CdioList_t *p_list, _cdio_list_iterfunc_t func, +void +_cdio_list_foreach (CdioList_t *p_list, _cdio_list_iterfunc_t func, void *p_user_data) { CdioListNode_t *node; cdio_assert (p_list != NULL); cdio_assert (func != 0); - + for (node = _cdio_list_begin (p_list); node != NULL; node = _cdio_list_node_next (node)) @@ -139,14 +137,14 @@ _cdio_list_foreach (CdioList_t *p_list, _cdio_list_iterfunc_t func, } CdioListNode_t * -_cdio_list_find (CdioList_t *p_list, _cdio_list_iterfunc_t cmp_func, +_cdio_list_find (CdioList_t *p_list, _cdio_list_iterfunc_t cmp_func, void *p_user_data) { CdioListNode_t *p_node; cdio_assert (p_list != NULL); cdio_assert (cmp_func != 0); - + for (p_node = _cdio_list_begin (p_list); p_node != NULL; p_node = _cdio_list_node_next (p_node)) @@ -181,14 +179,14 @@ _cdio_list_node_next (CdioListNode_t *p_node) return NULL; } -void +void _cdio_list_node_free (CdioListNode_t *p_node, int free_data) { CdioList_t *p_list; CdioListNode_t *prev_node; cdio_assert (p_node != NULL); - + p_list = p_node->list; cdio_assert (_cdio_list_length (p_list) > 0); @@ -243,13 +241,11 @@ _cdio_list_node_data (CdioListNode_t *p_node) /* eof */ - - -/* + +/* * Local variables: * c-file-style: "gnu" * tab-width: 8 * indent-tabs-mode: nil * End: */ - diff --git a/src/libcdio/driver/logging.c b/src/libcdio/driver/logging.c index ef54ab87..b89ab37a 100644 --- a/src/libcdio/driver/logging.c +++ b/src/libcdio/driver/logging.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003, 2004, 2008, 2011, 2012 + Copyright (C) 2003, 2004, 2008, 2011, 2012, 2015 Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel @@ -33,8 +33,9 @@ #endif #include -#include #include "cdio_assert.h" +#include "portable.h" +#include cdio_log_level_t cdio_loglevel_default = CDIO_LOG_WARN; @@ -96,10 +97,24 @@ static void cdio_logv(cdio_log_level_t level, const char format[], va_list args) { char buf[1024] = { 0, }; - static int in_recursion = 0; - if (in_recursion) - cdio_assert_not_reached (); + /* _handler() is user defined and we want to make sure _handler() + doesn't call us, cdio_logv. in_recursion is used for that, however + it has a problem in multi-threaded programs. I'm not sure how to + handle multi-threading and recursion checking both. For now, we'll + leave in the recursion checking, at the expense of handling + multi-threaded log calls. To ameliorate this, we'll check the log + level and handle calls where there is no output, before the + recursion check. + */ + static int in_recursion = 0; + + if (level < cdio_loglevel_default) return; + + if (in_recursion) { + /* Can't use cdio_assert_not_reached() as that may call cdio_logv */ + assert(0); + } in_recursion = 1; diff --git a/src/libcdio/driver/memory.c b/src/libcdio/driver/memory.c index a5aa0b7c..a887b9ad 100644 --- a/src/libcdio/driver/memory.c +++ b/src/libcdio/driver/memory.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Robert Kausch + Copyright (C) 2014-2015 Robert Kausch This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,6 @@ void cdio_free (void *p_memory) { - if (p_memory == NULL) return; - - free(p_memory); + if (p_memory != NULL) + free(p_memory); } diff --git a/src/libcdio/cdio/portable.h b/src/libcdio/driver/portable.h similarity index 100% rename from src/libcdio/cdio/portable.h rename to src/libcdio/driver/portable.h diff --git a/src/libcdio/driver/sector.c b/src/libcdio/driver/sector.c index c5367413..ebfb4dc3 100644 --- a/src/libcdio/driver/sector.c +++ b/src/libcdio/driver/sector.c @@ -1,5 +1,6 @@ /* - Copyright (C) 2004, 2005, 2011, 2012, 2014 Rocky Bernstein + Copyright (C) 2004, 2005, 2011, 2012, 2014, 2016 + Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel This program is free software: you can redistribute it and/or modify @@ -24,8 +25,8 @@ #include #include #include -#include #include "cdio_assert.h" +#include "portable.h" #ifdef HAVE_STDIO_H #include @@ -36,8 +37,6 @@ #include -// static const char _rcsid[] = "$Id: sector.c,v 1.5 2005/02/06 04:20:25 rocky Exp $"; - /*! String of bytes used to identify the beginning of a Mode 1 or Mode 2 sector. */ const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE] = diff --git a/src/libcdio/iso9660/iso9660.c b/src/libcdio/iso9660/iso9660.c index 84fda584..009a88b1 100644 --- a/src/libcdio/iso9660/iso9660.c +++ b/src/libcdio/iso9660/iso9660.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2009, 2013-2014 Rocky Bernstein + Copyright (C) 2003-2009, 2013-2014, 2016 Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel This program is free software: you can redistribute it and/or modify @@ -31,7 +31,6 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'}; #include #include #include -#include #include #include @@ -92,7 +91,7 @@ timegm(struct tm *tm) #endif #ifndef HAVE_GMTIME_R -struct tm * +static struct tm * gmtime_r(const time_t *timer, struct tm *result) { struct tm *tmp = gmtime(timer); @@ -106,7 +105,7 @@ gmtime_r(const time_t *timer, struct tm *result) #endif #ifndef HAVE_LOCALTIME_R -struct tm * +static struct tm * localtime_r(const time_t *timer, struct tm *result) { struct tm *tmp = localtime(timer); @@ -119,8 +118,6 @@ localtime_r(const time_t *timer, struct tm *result) } #endif -// static const char _rcsid[] = "$Id: iso9660.c,v 1.41 2008/06/25 08:01:54 rocky Exp $"; - /* Variables to hold debugger-helping enumerations */ enum iso_enum1_s iso_enums1; enum iso_flag_enum_s iso_flag_enums; diff --git a/src/libcdio/iso9660/iso9660_fs.c b/src/libcdio/iso9660/iso9660_fs.c index f9fd1695..f5b0ebe6 100644 --- a/src/libcdio/iso9660/iso9660_fs.c +++ b/src/libcdio/iso9660/iso9660_fs.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2008, 2011-2014 Rocky Bernstein + Copyright (C) 2003-2008, 2011-2015 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel This program is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ along with this program. If not, see . */ /* iso9660 filesystem-based routines */ - + #if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) #include "config.h" #define __CDIO_CONFIG_H__ 1 @@ -47,7 +47,6 @@ #include #include #include -#include /* Private headers */ #include "cdio_assert.h" @@ -264,6 +263,7 @@ static bool check_pvd (const iso9660_pvd_t *p_pvd, cdio_log_level_t log_level) { if ( ISO_VD_PRIMARY != from_711(p_pvd->type) ) { +// Commented out for Rufus usage // cdio_log (log_level, "unexpected PVD type %d", p_pvd->type); return false; } @@ -443,6 +443,7 @@ iso9660_ifs_read_pvd_loglevel (const iso9660_t *p_iso, cdio_log_level_t log_level) { if (0 == iso9660_iso_seek_read (p_iso, p_pvd, ISO_PVD_SECTOR, 1)) { +// Commented out for Rufus usage // cdio_log ( log_level, "error reading PVD sector (%d)", ISO_PVD_SECTOR ); return false; } @@ -715,6 +716,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa, iso711_t i_fname; unsigned int stat_len; iso9660_stat_t *p_stat; + bool err; if (!dir_len) return NULL; @@ -731,8 +733,16 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa, } p_stat->type = (p_iso9660_dir->file_flags & ISO_DIRECTORY) ? _STAT_DIR : _STAT_FILE; - p_stat->lsn = from_733 (p_iso9660_dir->extent); - p_stat->size = from_733 (p_iso9660_dir->size); + p_stat->lsn = from_733_with_err (p_iso9660_dir->extent, &err); + if (err) { + free(p_stat); + return NULL; + } + p_stat->size = from_733_with_err (p_iso9660_dir->size, &err); + if (err) { + free(p_stat); + return NULL; + } p_stat->secsize = _cdio_len2blocks (p_stat->size, ISO_BLOCKSIZE); p_stat->rr.b3_rock = dunno; /*FIXME should do based on mask */ p_stat->b_xa = false; @@ -1087,6 +1097,12 @@ _fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root, p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, p_iso->b_xa, p_iso->u_joliet_level); + if (!p_stat) { + cdio_warn("Bad directory information for %s", splitpath[0]); + free(_dirbuf); + return NULL; + } + cmp = strcmp(splitpath[0], p_stat->filename); if ( 0 != cmp && 0 == p_iso->u_joliet_level @@ -1334,24 +1350,38 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]) unsigned offset = 0; uint8_t *_dirbuf = NULL; CdioList_t *retval = _cdio_list_new (); + const size_t dirbuf_len = p_stat->secsize * ISO_BLOCKSIZE; - _dirbuf = calloc(1, p_stat->secsize * ISO_BLOCKSIZE); + + if (!dirbuf_len) + { + cdio_warn("Invalid directory buffer sector size %u", p_stat->secsize); + free(p_stat->rr.psz_symlink); + free(p_stat); + _cdio_list_free (retval, true); + return NULL; + } + + _dirbuf = calloc(1, dirbuf_len); if (!_dirbuf) { - cdio_warn("Couldn't calloc(1, %d)", p_stat->secsize * ISO_BLOCKSIZE); - _cdio_list_free (retval, true); + cdio_warn("Couldn't calloc(1, %lu)", (unsigned long)dirbuf_len); + free(p_stat->rr.psz_symlink); + free(p_stat); + _cdio_list_free (retval, true); return NULL; } ret = iso9660_iso_seek_read (p_iso, _dirbuf, p_stat->lsn, p_stat->secsize); - if (ret != ISO_BLOCKSIZE*p_stat->secsize) - { - _cdio_list_free (retval, true); - free (_dirbuf); - return NULL; - } + if (ret != dirbuf_len) { + _cdio_list_free (retval, true); + free(p_stat->rr.psz_symlink); + free(p_stat); + free (_dirbuf); + return NULL; + } - while (offset < (p_stat->secsize * ISO_BLOCKSIZE)) + while (offset < (dirbuf_len)) { iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset]; iso9660_stat_t *p_iso9660_stat; @@ -1372,15 +1402,14 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]) } free (_dirbuf); + free(p_stat->rr.psz_symlink); + free (p_stat); - if (offset != (p_stat->secsize * ISO_BLOCKSIZE)) { - free (p_stat); + if (offset != dirbuf_len) { _cdio_list_free (retval, true); return NULL; } - free (p_stat->rr.psz_symlink); - free (p_stat); return retval; } } diff --git a/src/libcdio/iso9660/rock.c b/src/libcdio/iso9660/rock.c index e29abb11..00a22e89 100644 --- a/src/libcdio/iso9660/rock.c +++ b/src/libcdio/iso9660/rock.c @@ -168,8 +168,27 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir, while (len > 1){ /* There may be one byte for padding somewhere */ rr = (iso_extension_record_t *) chr; - if (rr->len == 0) goto out; /* Something got screwed up here */ sig = *chr+(*(chr+1) << 8); + switch(sig){ + case SIG('S','P'): + case SIG('C','E'): + case SIG('E','R'): + case SIG('R','R'): + case SIG('P','X'): + case SIG('P','N'): + case SIG('S','L'): + case SIG('N','M'): + case SIG('C','L'): + case SIG('P','L'): + case SIG('T','F'): + case SIG('Z','F'): + break; + default: + /* Something got screwed up here */ + goto out; + } + + if (rr->len == 0) goto out; /* Something got screwed up here */ chr += rr->len; len -= rr->len; diff --git a/src/libcdio/mmc/mmc_private.h b/src/libcdio/mmc/mmc_private.h new file mode 100644 index 00000000..76444718 --- /dev/null +++ b/src/libcdio/mmc/mmc_private.h @@ -0,0 +1,3 @@ +/* placeholder for unused MMC helper routines. */ + +typedef driver_return_code_t (*mmc_run_cmd_fn_t) ( void ); diff --git a/src/libcdio/udf/udf_fs.c b/src/libcdio/udf/udf_fs.c index a3b10d0a..a0a39034 100644 --- a/src/libcdio/udf/udf_fs.c +++ b/src/libcdio/udf/udf_fs.c @@ -167,7 +167,7 @@ udf_get_lba(const udf_file_entry_t *p_udf_fe, { /* The allocation descriptor field is filled with short_ad's. */ udf_short_ad_t *p_ad = (udf_short_ad_t *) - (p_udf_fe->u.ext_attr + p_udf_fe->i_extended_attr); + (p_udf_fe->u.ext_attr + uint32_from_le(p_udf_fe->i_extended_attr)); *start = uint32_from_le(p_ad->pos); *end = *start + @@ -179,7 +179,7 @@ udf_get_lba(const udf_file_entry_t *p_udf_fe, { /* The allocation descriptor field is filled with long_ad's */ udf_long_ad_t *p_ad = (udf_long_ad_t *) - (p_udf_fe->u.ext_attr + p_udf_fe->i_extended_attr); + (p_udf_fe->u.ext_attr + uint32_from_le(p_udf_fe->i_extended_attr)); *start = uint32_from_le(p_ad->loc.lba); /* ignore partition number */ *end = *start + @@ -190,7 +190,7 @@ udf_get_lba(const udf_file_entry_t *p_udf_fe, case ICBTAG_FLAG_AD_EXTENDED: { udf_ext_ad_t *p_ad = (udf_ext_ad_t *) - (p_udf_fe->u.ext_attr + p_udf_fe->i_extended_attr); + (p_udf_fe->u.ext_attr + uint32_from_le(p_udf_fe->i_extended_attr)); *start = uint32_from_le(p_ad->ext_loc.lba); /* ignore partition number */ *end = *start + @@ -739,7 +739,7 @@ udf_readdir(udf_dirent_t *p_udf_dirent) const unsigned int i_len = p_udf_dirent->fid->i_file_id; if (DRIVER_OP_SUCCESS != udf_read_sectors(p_udf, &p_udf_dirent->fe, p_udf->i_part_start - + p_udf_dirent->fid->icb.loc.lba, 1)) { + + uint32_from_le(p_udf_dirent->fid->icb.loc.lba), 1)) { udf_dirent_free(p_udf_dirent); return NULL; } diff --git a/src/rufus.rc b/src/rufus.rc index 3420406a..ef10c604 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.13.1069" +CAPTION "Rufus 2.13.1070" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -334,8 +334,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,13,1069,0 - PRODUCTVERSION 2,13,1069,0 + FILEVERSION 2,13,1070,0 + PRODUCTVERSION 2,13,1070,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -352,13 +352,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.13.1069" + VALUE "FileVersion", "2.13.1070" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.13.1069" + VALUE "ProductVersion", "2.13.1070" END END BLOCK "VarFileInfo"