1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[iso] update libcdio to v0.93

* Also fix a memory leak introduced vy v0.93 in cdio_free()
This commit is contained in:
Pete Batard 2014-10-31 18:52:23 +00:00
parent 7090a0371a
commit ea817cbc2c
29 changed files with 305 additions and 164 deletions

View file

@ -1,5 +1,6 @@
/* -*- c -*-
Copyright (C) 2003, 2004, 2005, 2008, 2009 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2003, 2004, 2005, 2008, 2009, 2014
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
@ -45,8 +46,6 @@ extern "C" {
/** This is an opaque structure for the CD object. */
typedef struct _CdIo CdIo_t;
typedef struct cdtext_s cdtext_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
@ -70,4 +69,7 @@ extern "C" {
/* Track-related functions. */
#include <cdio/track.h>
/* Memory management functions. */
#include <cdio/memory.h>
#endif /* __CDIO_H__ */

View file

@ -1 +1,2 @@
/* Empty placeholder */
/* Placeholder */
typedef struct cdtext_s cdtext_t;

View file

@ -1,7 +1,7 @@
/* -*- c -*-
Copyright (C) 2004, 2005, 2006, 2008, 2010, 2012 Rocky Bernstein
<rocky@gnu.org>
Copyright (C) 2004, 2005, 2006, 2008, 2010, 2012, 2014
Rocky Bernstein <rocky@gnu.org>
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
@ -61,9 +61,9 @@ extern "C" {
Get binary CD-Text information for a CdIo_t object.
@param p_cdio the CD object that may contain CD-Text information.
@return malloc'd pointer to raw CD-Text data as stored on the disc
or NULL if p_cdio is NULL or CD-Text information does not exist.
Return value should be freed when done with it and not NULL.
@return malloc'd pointer to raw CD-Text data as stored on the disc or
NULL if p_cdio is NULL or CD-Text information does not exist. Return
value must be freed with cdio_free() when done with it and not NULL.
*/
uint8_t * cdio_get_cdtext_raw (CdIo_t *p_cdio);
@ -101,8 +101,8 @@ extern "C" {
@return the media catalog number or NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
Note: The caller must free the returned string with cdio_free()
when done with it.
*/
char * cdio_get_mcn (const CdIo_t *p_cdio);

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2012
Copyright (C) 2003-2008, 2012-2013
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
@ -859,7 +859,7 @@ iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
lsn and return information about it.
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value.
Caller must free return value using iso9660_stat_free().
*/
#define iso9660_fs_find_lsn iso9660_find_fs_lsn
iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
@ -870,7 +870,7 @@ iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
lsn and return information about it.
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value.
Caller must free return value using iso9660_stat_free().
*/
iso9660_stat_t *iso9660_fs_find_lsn_with_path(CdIo_t *p_cdio, lsn_t i_lsn,
/*out*/ char **ppsz_path);
@ -880,7 +880,7 @@ iso9660_stat_t *iso9660_fs_find_lsn_with_path(CdIo_t *p_cdio, lsn_t i_lsn,
lsn and return information about it.
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value.
Caller must free return value using iso9660_stat_free().
*/
iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
@ -897,12 +897,16 @@ iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
*ppsz_path when you are done using it.
@return stat_t of entry if we found lsn, or NULL otherwise.
Caller must free return value.
Caller must free return value using iso9660_stat_free().
*/
iso9660_stat_t *iso9660_ifs_find_lsn_with_path(iso9660_t *p_iso,
lsn_t i_lsn,
/*out*/ char **ppsz_path);
/*!
Free the passed iso9660_stat_t structure.
*/
void iso9660_stat_free(iso9660_stat_t *p_stat);
/*!
Return file status for psz_path. NULL is returned on error.
@ -951,7 +955,7 @@ iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
pointers for the files inside that directory. The caller must free the
returned result.
returned result using _cdio_list_free().
b_mode2 is historical. It is not used.
*/
@ -960,7 +964,7 @@ CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[],
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
pointers for the files inside that directory. The caller must free
the returned result.
the returned result using _cdio_list_free().
*/
CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);

View file

@ -97,11 +97,7 @@ cdio_log_handler_t cdio_log_set_handler (cdio_log_handler_t new_handler);
*/
void cdio_log (cdio_log_level_t level,
const char format[], ...) GNUC_PRINTF(2, 3);
#if defined(__GNUC__)
/* See http://clang-analyzer.llvm.org/annotations.html#custom_assertions */
void cdio_assert_log (const char format[], ...)
GNUC_PRINTF(1, 2) __attribute__((__noreturn__));
#endif
/**
* Handle a debugging message.
*

41
src/libcdio/cdio/memory.h Normal file
View file

@ -0,0 +1,41 @@
/*
Copyright (C) 2014 Robert Kausch <robert.kausch@freac.org>
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file memory.h
*
* \brief memory management utility functions.
*
*/
#ifndef CDIO_MEMORY_H_
#define CDIO_MEMORY_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*!
Free the passed pointer.
*/
void cdio_free(void *p_memory);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CDIO_MEMORY_H_ */

View file

@ -211,8 +211,8 @@ extern "C" {
@return the International Standard Recording Code (ISRC) or NULL
if there is none or we don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
Note: The caller must free the returned string with cdio_free()
when done with it.
*/
char * cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track);

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2008, 2012 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2008, 2012, 2014 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2006 Burkhard Plaum <plaum@ipf.uni-stuttgart.de>
This program is free software: you can redistribute it and/or modify
@ -52,7 +52,7 @@ void cdio_charset_converter_destroy(cdio_charset_coverter_t*cnv);
* \param dst_len If non NULL, returns the length of the destination string
* \returns true if conversion was sucessful, false else.
*
* The destination string must be freed by the caller with free().
* The destination string must be freed by the caller with cdio_free().
* If you pass -1 for src_len, strlen() will be used.
*/
@ -69,6 +69,8 @@ bool cdio_charset_convert(cdio_charset_coverter_t*cnv,
*
* This is a convenience function, which creates a charset converter,
* converts one string and destroys the charset converter.
*
* The destination string must be freed by the caller with cdio_free().
*/
@ -83,8 +85,10 @@ bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
* \returns true if conversion was sucessful, false else.
*
* This is a convenience function, which creates a charset converter,
* converts one string and destroys the charset converter. If you pass -1
* for src_len, strlen() will be used.
* converts one string and destroys the charset converter.
*
* The destination string must be freed by the caller with cdio_free().
* If you pass -1 for src_len, strlen() will be used.
*/
@ -95,7 +99,7 @@ bool cdio_charset_to_utf8(const char *src, size_t src_len, cdio_utf8_t **dst,
/** \brief Convert an UTF8 string to UTF-16 (allocate returned string)
* \param str Source string
* \returns NULL if the conversion was unsuccesful. Caller must free the
* returned string.
* returned string with cdio_free().
* This is a convenience function available on Windows platforms only.
*/
wchar_t* cdio_utf8_to_wchar(const char* str);

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2004, 2005, 2006, 2008, 2010, 2012
Copyright (C) 2004, 2005, 2006, 2008, 2010, 2012, 2014
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
@ -101,7 +101,8 @@ _cdio_strdup_upper (const char str[]);
/* Duplicate path and make it platform compliant. Typically needed for
MinGW/MSYS where a "/c/..." path must be translated to "c:/..." for
use with fopen(), etc. Returned string must be freed by the caller. */
use with fopen(), etc. Returned string must be freed by the caller
using cdio_free(). */
char *
_cdio_strdup_fixpath (const char path[]);

View file

@ -8,13 +8,13 @@
/*! 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.90 i686-pc-mingw32"
#define CDIO_VERSION "0.93 i686-pc-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 90
#define LIBCDIO_VERSION_NUM 93
extern const unsigned int libcdio_version_num; /**< = LIBCDIO_VERSION_NUM */

View file

@ -146,7 +146,7 @@ iso9660_get_xa_attr_str (uint16_t xa_attr);
/*!
Allocates and initalizes a new iso9600_xa_t variable and returns
it. The caller should free the returned result.
it. The caller must free the returned result using iso9660_xa_free().
@see iso9660_xa
*/
@ -154,6 +154,14 @@ iso9660_xa_t *
iso9660_xa_init (iso9660_xa_t *_xa, uint16_t uid, uint16_t gid, uint16_t attr,
uint8_t filenum);
/*!
Frees the passed iso9600_xa_t structure.
@see iso9660_xa
*/
void
iso9660_xa_free (iso9660_xa_t *_xa);
#ifdef __cplusplus
}

View file

@ -22,6 +22,7 @@
<ClCompile Include="..\disc.c" />
<ClCompile Include="..\ds.c" />
<ClCompile Include="..\logging.c" />
<ClCompile Include="..\memory.c" />
<ClCompile Include="..\read.c" />
<ClCompile Include="..\sector.c" />
<ClCompile Include="..\track.c" />
@ -34,6 +35,7 @@
<ClInclude Include="..\..\cdio\cdio.h" />
<ClInclude Include="..\..\cdio\ds.h" />
<ClInclude Include="..\..\cdio\logging.h" />
<ClInclude Include="..\..\cdio\memory.h" />
<ClInclude Include="..\..\cdio\sector.h" />
<ClInclude Include="..\..\cdio\types.h" />
<ClInclude Include="..\..\cdio\util.h" />

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
@ -41,6 +41,9 @@
<ClCompile Include="..\utf8.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\memory.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\_cdio_stdio.h">
@ -85,5 +88,8 @@
<ClInclude Include="..\..\cdio\version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\cdio\memory.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -73,7 +73,7 @@ static inline int _stati64_utf8(const char *path, struct _stati64 *buffer) {
int ret;
wchar_t* wpath = cdio_utf8_to_wchar(path);
ret = _wstati64(wpath, buffer);
free(wpath);
cdio_free(wpath);
return ret;
}
#define CDIO_STAT_CALL _stati64_utf8
@ -262,7 +262,7 @@ cdio_stdio_new(const char pathname[])
{
cdio_warn ("could not retrieve file info for `%s': %s",
pathdup, strerror (errno));
free(pathdup);
cdio_free(pathdup);
return NULL;
}

View file

@ -35,8 +35,19 @@
extern "C" {
#endif /* __cplusplus */
extern const char * cdio_dirname(const char *fname);
extern const char *cdio_abspath(const char *cwd, const char *fname);
/*!
Get directory name from file name.
Callers must free return value after use.
*/
extern char *cdio_dirname(const char *fname);
/*!
Construct an absolute file name from path and file name.
Callers must free return value after use.
*/
extern char *cdio_abspath(const char *cwd, const char *fname);
/* Opaque type */
typedef struct _CdioDataSource CdioDataSource_t;

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2003, 2004, 2005, 2008, 2011, 2012
Copyright (C) 2003, 2004, 2005, 2008, 2011, 2012, 2014
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@ -77,8 +77,8 @@ cdio_get_cdtext (CdIo *obj)
@param obj the CD object that may contain CD-TEXT information.
@return pointer to allocated memory area holding the raw CD-TEXT
or NULL if obj is NULL or CD-TEXT does not exist.
free() when done.
or NULL if obj is NULL or CD-TEXT does not exist. Return value
must be freed with cdio_free() when done with it and not NULL.
*/
uint8_t *
cdio_get_cdtext_raw (CdIo *obj)

View file

@ -0,0 +1,42 @@
/*
Copyright (C) 2014 Robert Kausch <robert.kausch@freac.org>
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
# define __CDIO_CONFIG_H__ 1
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <cdio/memory.h>
#include <cdio/types.h>
/*!
Free the passed pointer.
@param p_memory a pointer to memory allocated by a libcdio funtion.
*/
void
cdio_free (void *p_memory)
{
if (p_memory == NULL) return;
free(p_memory);
}

View file

@ -1,20 +1,19 @@
/*
Copyright (C) 2004, 2005, 2011, 2012 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2004, 2005, 2011, 2012, 2014 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@ -81,9 +80,9 @@ cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
f = lsn + CDIO_CD_MAX_LSN;
}
if (m > 6) {
if (m > 99) {
cdio_warn ("number of minutes (%d) truncated to 99.", m);
m = 6;
m = 99;
}
msf->m = cdio_to_bcd8 (m);

View file

@ -294,8 +294,8 @@ cdio_get_track_lsn(const CdIo_t *p_cdio, track_t u_track)
Return the International Standard Recording Code (ISRC) for track number
u_track in p_cdio. Track numbers start at 1.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
Note: The caller must free the returned string with cdio_free()
when done with it.
*/
char *
cdio_get_track_isrc (const CdIo_t *p_cdio, track_t u_track)

View file

@ -1,6 +1,6 @@
/*
Copyright (C) 2006, 2008 Burkhard Plaum <plaum@ipf.uni-stuttgart.de>
Copyright (C) 2011 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2011, 2014 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2012 Pete Batard <pete@akeo.ie>
This program is free software: you can redistribute it and/or modify
@ -41,6 +41,7 @@
#include <cdio/utf8.h>
#include <cdio/logging.h>
#include <cdio/memory.h>
/* Windows requires some basic UTF-8 support outside of Joliet */
#if defined(_WIN32)
@ -107,8 +108,8 @@ FILE* fopen_utf8(const char* filename, const char* mode)
wchar_t* wfilename = cdio_utf8_to_wchar(filename);
wchar_t* wmode = cdio_utf8_to_wchar(mode);
ret = _wfopen(wfilename, wmode);
free(wfilename);
free(wmode);
cdio_free(wfilename);
cdio_free(wmode);
return ret;
}
#endif
@ -136,7 +137,7 @@ static void bgav_hexdump(uint8_t * data, int len, int linebreak)
int i;
int bytes_written = 0;
int imax;
while(bytes_written < len)
{
imax = (bytes_written + linebreak > len) ? len - bytes_written : linebreak;
@ -183,11 +184,11 @@ do_convert(iconv_t cd, const char * src, int src_len,
#if 0
fprintf(stderr, "Converting:\n");
bgav_hexdump(src, src_len, 16);
#endif
#endif
alloc_size = src_len + BYTES_INCREMENT;
inbytesleft = src_len;
/* We reserve space here to add a final '\0' */
outbytesleft = alloc_size-1;
@ -195,10 +196,10 @@ do_convert(iconv_t cd, const char * src, int src_len,
inbuf = (char *)src;
outbuf = ret;
while(1)
{
if(iconv(cd, (ICONV_CONST char **)&inbuf, &inbytesleft,
&outbuf, &outbytesleft) == (size_t)-1)
{
@ -241,7 +242,7 @@ do_convert(iconv_t cd, const char * src, int src_len,
bgav_hexdump(src, src_len, 16);
fprintf(stderr, "dst:\n");
bgav_hexdump((uint8_t*)(ret), (int)(outbuf - ret), 16);
#endif
#endif
return true;
}
@ -292,7 +293,7 @@ bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
/* Eliminate empty strings */
le_dst = cdio_utf8_to_wchar(src);
if ((le_dst == NULL) || (le_dst[0] == 0)) {
free(le_dst);
cdio_free(le_dst);
return false;
}

View file

@ -139,7 +139,8 @@ _cdio_strdup_upper (const char str[])
}
/* Convert MinGW/MSYS paths that start in "/c/..." to "c:/..."
so that they can be used with fopen(), stat(), etc. */
so that they can be used with fopen(), stat(), etc.
Returned string must be freed by the caller using cdio_free().*/
char *
_cdio_strdup_fixpath (const char path[])
{

View file

@ -21,6 +21,7 @@
<ItemGroup>
<ClInclude Include="..\..\cdio\bytesex.h" />
<ClInclude Include="..\..\cdio\cdio.h" />
<ClInclude Include="..\..\cdio\cdtext.h" />
<ClInclude Include="..\..\cdio\iso9660.h" />
<ClInclude Include="..\..\cdio\logging.h" />
<ClInclude Include="..\..\cdio\utf8.h" />

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
@ -47,6 +47,9 @@
<ClInclude Include="..\..\driver\filemode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\cdio\cdtext.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\iso9660_fs.c">

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2003-2009, 2013 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2003-2009, 2013-2014 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
@ -360,7 +360,7 @@ iso9660_set_ltime_with_timezone(const struct tm *p_tm,
{
char *_pvd_date = (char *) pvd_date;
memset (_pvd_date, '0', 16);
memset (_pvd_date, (int) '0', 16);
pvd_date->lt_gmtoff = (iso712_t) 0; /* Start out with time zone GMT. */
if (!p_tm) return;

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 2003-2008, 2011-2013 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2003-2008, 2011-2014 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
@ -754,6 +754,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
if (!p_stat_new)
{
cdio_warn("Couldn't calloc(1, %d)", (int)(sizeof(iso9660_stat_t)+i_rr_fname+2));
free(p_stat);
return NULL;
}
memcpy(p_stat_new, p_stat, stat_len);
@ -1270,12 +1271,15 @@ iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[], bool b_mode2)
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %d)", p_stat->secsize * ISO_BLOCKSIZE);
_cdio_list_free (retval, true);
return NULL;
}
if (cdio_read_data_sectors (p_cdio, _dirbuf, p_stat->lsn,
ISO_BLOCKSIZE, p_stat->secsize))
return NULL;
ISO_BLOCKSIZE, p_stat->secsize)) {
_cdio_list_free (retval, true);
return NULL;
}
while (offset < (p_stat->secsize * ISO_BLOCKSIZE))
{
@ -1334,12 +1338,14 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[])
if (!_dirbuf)
{
cdio_warn("Couldn't calloc(1, %d)", p_stat->secsize * ISO_BLOCKSIZE);
_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;
}
@ -1415,8 +1421,9 @@ find_lsn_recurse (void *p_image, iso9660_readdir_t iso9660_readdir,
iso9660_stat_t *ret_stat = calloc(1, len2);
if (!ret_stat)
{
cdio_warn("Couldn't calloc(1, %d)", len2);
return NULL;
_cdio_list_free (dirlist, true);
cdio_warn("Couldn't calloc(1, %d)", len2);
return NULL;
}
memcpy(ret_stat, statbuf, len2);
_cdio_list_free (entlist, true);
@ -1510,6 +1517,16 @@ iso9660_ifs_find_lsn_with_path(iso9660_t *p_iso, lsn_t i_lsn,
"/", i_lsn, ppsz_full_filename);
}
/*!
Free the passed iso9660_stat_t structure.
*/
void
iso9660_stat_free(iso9660_stat_t *p_stat)
{
if (p_stat != NULL)
free(p_stat);
}
/*!
Return true if ISO 9660 image has extended attrributes (XA).
*/
@ -1563,11 +1580,11 @@ iso_have_rr_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
if ( have_rr != yep) {
have_rr = iso_have_rr_traverse (p_iso, p_stat, &splitpath[1], pu_file_limit);
}
free(p_stat);
if (have_rr != nope) {
free (_dirbuf);
return have_rr;
}
free(p_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);
*pu_file_limit = (*pu_file_limit)-1;

View file

@ -1,7 +1,7 @@
/*
Copyright (C) 2005, 2008, 2010, 2011 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2005, 2008, 2010-2011, 2014 Rocky Bernstein <rocky@gnu.org>
Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale
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
the Free Software Foundation, either version 3 of the License, or
@ -51,7 +51,7 @@ iso_rock_tf_flag_t iso_rock_tf_flag;
valgrind complaint.
*/
static bool
realloc_symlink(/*in/out*/ iso9660_stat_t *p_stat, uint8_t i_grow)
realloc_symlink(/*in/out*/ iso9660_stat_t *p_stat, uint8_t i_grow)
{
if (!p_stat->rr.i_symlink) {
const uint16_t i_max = 2*i_grow+1;
@ -138,15 +138,15 @@ realloc_symlink(/*in/out*/ iso9660_stat_t *p_stat, uint8_t i_grow)
sizeof(iso9660_dtime_t)); \
cnt += sizeof(iso9660_dtime_t); \
} \
}
}
/*!
/*!
Get
@return length of name field; 0: not found, -1: to be ignored
@return length of name field; 0: not found, -1: to be ignored
*/
int
get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
/*out*/ char * psz_name,
int
get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
/*out*/ char * psz_name,
/*in/out*/ iso9660_stat_t *p_stat)
{
int len;
@ -165,19 +165,19 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
iso_extension_record_t * rr;
int sig;
int rootflag;
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);
chr += rr->len;
chr += rr->len;
len -= rr->len;
switch(sig){
case SIG('S','P'):
CHECK_SP(goto out);
break;
case SIG('C','E'):
case SIG('C','E'):
{
iso711_t i_fname = from_711(p_iso9660_dir->filename.len);
if ('\0' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
@ -190,7 +190,7 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
case SIG('E','R'):
p_stat->rr.b3_rock = yep;
cdio_debug("ISO 9660 Extensions: ");
{
{
int p;
for(p=0;p<rr->u.ER.len_id;p++) cdio_debug("%c",rr->u.ER.data[p]);
}
@ -265,13 +265,13 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
slen -= p_sl->len + 2;
p_oldsl = p_sl;
p_sl = (iso_rock_sl_part_t *) (((char *) p_sl) + p_sl->len + 2);
if (slen < 2) {
if (((rr->u.SL.flags & 1) != 0) && ((p_oldsl->flags & 1) == 0))
if (((rr->u.SL.flags & 1) != 0) && ((p_oldsl->flags & 1) == 0))
p_stat->rr.i_symlink += 1;
break;
}
/*
* If this component record isn't continued, then append a '/'.
*/
@ -288,7 +288,7 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
case SIG('R','E'):
free(buffer);
return -1;
case SIG('T','F'):
case SIG('T','F'):
/* Time stamp(s) for a file */
{
int cnt = 0;
@ -332,20 +332,20 @@ parse_rock_ridge_stat_internal(iso9660_dir_t *p_iso9660_dir,
len-=14;
if (len<0) len=0;
}
/* repeat:*/
{
int sig;
iso_extension_record_t * rr;
int rootflag;
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 = from_721(*chr);
chr += rr->len;
chr += rr->len;
len -= rr->len;
switch(sig){
case SIG('S','P'):
CHECK_SP(goto out);
@ -385,7 +385,7 @@ parse_rock_ridge_stat_internal(iso9660_dir_t *p_iso9660_dir,
}
}
break;
case SIG('T','F'):
case SIG('T','F'):
/* Time stamp(s) for a file */
{
int cnt = 0;
@ -437,13 +437,13 @@ parse_rock_ridge_stat_internal(iso9660_dir_t *p_iso9660_dir,
slen -= p_sl->len + 2;
p_oldsl = p_sl;
p_sl = (iso_rock_sl_part_t *) (((char *) p_sl) + p_sl->len + 2);
if (slen < 2) {
if (((rr->u.SL.flags & 1) != 0) && ((p_oldsl->flags & 1) == 0))
if (((rr->u.SL.flags & 1) != 0) && ((p_oldsl->flags & 1) == 0))
p_stat->rr.i_symlink += 1;
break;
}
/*
* If this component record isn't continued, then append a '/'.
*/
@ -461,7 +461,7 @@ parse_rock_ridge_stat_internal(iso9660_dir_t *p_iso9660_dir,
cdio_warn("Attempt to read p_stat for relocated directory");
goto out;
#ifdef FINISHED
case SIG('C','L'):
case SIG('C','L'):
{
iso9660_stat_t * reloc;
ISOFS_I(p_stat)->i_first_extent = from_733(rr->u.CL.location);
@ -492,14 +492,14 @@ parse_rock_ridge_stat_internal(iso9660_dir_t *p_iso9660_dir,
return 0;
}
int
parse_rock_ridge_stat(iso9660_dir_t *p_iso9660_dir,
int
parse_rock_ridge_stat(iso9660_dir_t *p_iso9660_dir,
/*out*/ iso9660_stat_t *p_stat)
{
int result;
if (!p_stat) return 0;
result = parse_rock_ridge_stat_internal(p_iso9660_dir, p_stat, 0);
/* if Rock-Ridge flag was reset and we didn't look for attributes
* behind eventual XA attributes, have a look there */
@ -518,7 +518,7 @@ _getbuf (void)
{
static char _buf[BUF_COUNT][BUF_SIZE];
static int _i = -1;
_i++;
_i %= BUF_COUNT;
@ -528,24 +528,24 @@ _getbuf (void)
}
/*!
Returns a string which interpreting the POSIX mode st_mode.
Returns a string which interpreting the POSIX mode st_mode.
For example:
\verbatim
drwxrws---
-rw-rw-r--
lrwxrwxrwx
\endverbatim
A description of the characters in the string follows
The 1st character is either "b" for a block device,
The 1st character is either "b" for a block device,
"c" for a character device, "d" if the entry is a directory, "l" for
a symbolic link, "p" for a pipe or FIFO, "s" for a "socket",
a symbolic link, "p" for a pipe or FIFO, "s" for a "socket",
or "-" if none of the these.
The 2nd to 4th characters refer to permissions for a user while the
the 5th to 7th characters refer to permissions for a group while, and
the 8th to 10h characters refer to permissions for everyone.
the 5th to 7th characters refer to permissions for a group while, and
the 8th to 10h characters refer to permissions for everyone.
In each of these triplets the first character (2, 5, 8) is "r" if
the entry is allowed to be read.
@ -569,7 +569,7 @@ iso9660_get_rock_attr_str(posix_mode_t st_mode)
if (S_ISBLK(st_mode))
result[ 0] = 'b';
else if (S_ISDIR(st_mode))
else if (S_ISDIR(st_mode))
result[ 0] = 'd';
else if (S_ISCHR(st_mode))
result[ 0] = 'c';
@ -577,16 +577,16 @@ iso9660_get_rock_attr_str(posix_mode_t st_mode)
result[ 0] = 'l';
else if (S_ISFIFO(st_mode))
result[ 0] = 'p';
else if (S_ISSOCK(st_mode))
else if (S_ISSOCK(st_mode))
result[ 0] = 's';
/* May eventually fill in others.. */
else
else
result[ 0] = '-';
result[ 1] = (st_mode & ISO_ROCK_IRUSR) ? 'r' : '-';
result[ 2] = (st_mode & ISO_ROCK_IWUSR) ? 'w' : '-';
if (st_mode & ISO_ROCK_ISUID)
if (st_mode & ISO_ROCK_ISUID)
result[ 3] = (st_mode & ISO_ROCK_IXUSR) ? 's' : 'S';
else
result[ 3] = (st_mode & ISO_ROCK_IXUSR) ? 'x' : '-';
@ -594,9 +594,9 @@ iso9660_get_rock_attr_str(posix_mode_t st_mode)
result[ 4] = (st_mode & ISO_ROCK_IRGRP) ? 'r' : '-';
result[ 5] = (st_mode & ISO_ROCK_IWGRP) ? 'w' : '-';
if (st_mode & ISO_ROCK_ISGID)
if (st_mode & ISO_ROCK_ISGID)
result[ 6] = (st_mode & ISO_ROCK_IXGRP) ? 's' : 'S';
else
else
result[ 6] = (st_mode & ISO_ROCK_IXGRP) ? 'x' : '-';
result[ 7] = (st_mode & ISO_ROCK_IROTH) ? 'r' : '-';
@ -611,10 +611,8 @@ iso9660_get_rock_attr_str(posix_mode_t st_mode)
/*!
Returns POSIX mode bitstring for a given file.
*/
mode_t
iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr)
mode_t
iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr)
{
return (mode_t) rr->st_mode;
}

View file

@ -151,6 +151,13 @@ iso9660_xa_init (iso9660_xa_t *_xa, uint16_t uid, uint16_t gid, uint16_t attr,
return _xa;
}
void
iso9660_xa_free (iso9660_xa_t *_xa)
{
if (_xa != NULL)
free(_xa);
}
/*!
Returns POSIX mode bitstring for a given file.
*/

View file

@ -1,5 +1,6 @@
/*
Copyright (C) 2005-2006, 2008, 2011, 2013 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2005-2006, 2008, 2011, 2013-2014
Rocky Bernstein <rocky@gnu.org>
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
@ -205,10 +206,9 @@ udf_get_lba(const udf_file_entry_t *p_udf_fe,
#define udf_PATH_DELIMITERS "/\\"
/* Searches p_udf_dirent a directory entry called psz_token.
Note p_udf_dirent is continuously updated. If the entry is
not found p_udf_dirent is useless and thus the caller should
not use it afterwards.
/* Searches p_udf_dirent for a directory entry called psz_token.
Note that p_udf_dirent may be replaced or freed during this call
and only the returned udf_dirent_t must be used afterwards.
*/
static
udf_dirent_t *
@ -221,20 +221,21 @@ udf_ff_traverse(udf_dirent_t *p_udf_dirent, char *psz_token)
if (!next_tok)
return p_udf_dirent; /* found */
else if (p_udf_dirent->b_dir) {
udf_dirent_t * p_udf_dirent2 = udf_opendir(p_udf_dirent);
udf_dirent_t * p_udf_dirent_next = udf_opendir(p_udf_dirent);
if (p_udf_dirent2) {
udf_dirent_t * p_udf_dirent3 =
udf_ff_traverse(p_udf_dirent2, next_tok);
if (p_udf_dirent_next) {
/* free p_udf_dirent to avoid leaking memory. */
udf_dirent_free(p_udf_dirent);
/* if p_udf_dirent3 is null p_udf_dirent2 is free'd. */
return p_udf_dirent3;
/* previous p_udf_dirent_next is freed by udf_ff_traverse. */
p_udf_dirent_next = udf_ff_traverse(p_udf_dirent_next, next_tok);
return p_udf_dirent_next;
}
}
}
}
if (p_udf_dirent)
free(p_udf_dirent->psz_name);
return NULL;
}
@ -253,20 +254,15 @@ udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name)
/* file position must be reset when accessing a new file */
p_udf_root->p_udf->i_position = 0;
strncpy(tokenline, psz_name, udf_MAX_PATHLEN);
tokenline[udf_MAX_PATHLEN-1] = '\0';
strncpy(tokenline, psz_name, udf_MAX_PATHLEN-1);
psz_token = strtok(tokenline, udf_PATH_DELIMITERS);
if (psz_token) {
/*** FIXME??? udf_dirent can be variable size due to the
extended attributes and descriptors. Given that, is this
correct?
*/
udf_dirent_t *p_udf_dirent =
udf_new_dirent(&p_udf_root->fe, p_udf_root->p_udf,
p_udf_root->psz_name, p_udf_root->b_dir,
p_udf_root->b_parent);
p_udf_file = udf_ff_traverse(p_udf_dirent, psz_token);
if (p_udf_file != p_udf_dirent)
udf_dirent_free(p_udf_dirent);
}
else if ( 0 == strncmp("/", psz_name, sizeof("/")) ) {
return udf_new_dirent(&p_udf_root->fe, p_udf_root->p_udf,
@ -299,7 +295,7 @@ unicode16_decode(const uint8_t *data, int i_len)
cdio_charset_to_utf8((char*)&data[1], i_len-1, &r, "UCS-2BE");
return r;
default:
/* Empty string, for calls that can't take a NULL pointer */
/* Empty string, as some existing sections can't take a NULL pointer */
r = (char*)calloc(1, 1);
return r;
}
@ -449,7 +445,7 @@ udf_open (const char *psz_path)
* returns the size of buffer needed for all data
* Note: this call accepts a NULL psz_volid, to retrieve the length required.
*/
int
int
udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid, unsigned int i_volid)
{
uint8_t data[UDF_BLOCKSIZE];
@ -475,10 +471,10 @@ udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid, unsigned int i_volid)
if (r == NULL)
return 0;
volid_len = strlen(r)+1; /* +1 for NUL terminator */
volid_len = strlen(r)+1; /* +1 for NUL terminator */
if (psz_volid != NULL) {
strncpy(psz_volid, r, MIN(volid_len, i_volid));
psz_volid[i_volid-1] = 0; /* strncpy does not always terminate the dest */
psz_volid[i_volid-1] = 0; /* strncpy does not always terminate the dest */
}
free(r);
@ -534,17 +530,17 @@ udf_get_logical_volume_id(udf_t *p_udf, /*out*/ char *psz_logvolid, unsigned int
if (psz_logvolid != NULL)
psz_logvolid[0] = 0;
if (DRIVER_OP_SUCCESS != udf_read_sectors (p_udf, p_logvol, p_udf->lvd_lba, 1) )
if (DRIVER_OP_SUCCESS != udf_read_sectors (p_udf, p_logvol, p_udf->lvd_lba, 1) )
return 0;
r = unicode16_decode((uint8_t *) p_logvol->logvol_id, p_logvol->logvol_id[127]);
if (r == NULL)
return 0;
logvolid_len = strlen(r)+1; /* +1 for NUL terminator */
logvolid_len = strlen(r)+1; /* +1 for NUL terminator */
if (psz_logvolid != NULL) {
strncpy(psz_logvolid, r, MIN(logvolid_len, i_logvolid));
psz_logvolid[i_logvolid-1] = 0; /* strncpy does not always terminate the dest */
psz_logvolid[i_logvolid-1] = 0; /* strncpy does not always terminate the dest */
}
free(r);
@ -748,9 +744,9 @@ udf_readdir(udf_dirent_t *p_udf_dirent)
return NULL;
}
free_and_null(p_udf_dirent->psz_name);
p = (uint8_t*)p_udf_dirent->fid->u.imp_use.data + p_udf_dirent->fid->u.i_imp_use;
p_udf_dirent->psz_name = unicode16_decode(p, i_len);
free_and_null(p_udf_dirent->psz_name);
p = (uint8_t*)p_udf_dirent->fid->u.imp_use.data + p_udf_dirent->fid->u.i_imp_use;
p_udf_dirent->psz_name = unicode16_decode(p, i_len);
}
return p_udf_dirent;
}

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 1.4.11.521"
CAPTION "Rufus 1.4.11.522"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -165,7 +165,7 @@ END
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
CAPTION "Rufus 1.4.11.521"
CAPTION "Rufus 1.4.11.522"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -428,8 +428,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,11,521
PRODUCTVERSION 1,4,11,521
FILEVERSION 1,4,11,522
PRODUCTVERSION 1,4,11,522
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -446,13 +446,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.11.521"
VALUE "FileVersion", "1.4.11.522"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.11.521"
VALUE "ProductVersion", "1.4.11.522"
END
END
BLOCK "VarFileInfo"