> > /usr/include/cdio/iso9660.h:277:45: error: flexible array member
> > 'iso9660_dir_s::filename' not at end of 'struct iso9660_pvd_s'
> > char filename[EMPTY_ARRAY_SIZE];
> > ^
> > /usr/include/cdio/iso9660.h:310:20: note: next member 'char
> > iso9660_pvd_s::root_directory_filename' declared here
> > char root_directory_filename; /**< Is '\\0' or root
> > ^~~~~~~~~~~~~~~~~~~~~~~
> > /usr/include/cdio/iso9660.h:283:8: note: in the definition of 'struct
> > iso9660_pvd_s'
> > struct iso9660_pvd_s {
> > ^~~~~~~~~~~~~
> > /usr/include/cdio/iso9660.h:277:45: error: flexible array member
> > 'iso9660_dir_s::filename' not at end of 'struct iso9660_svd_s'
> > char filename[EMPTY_ARRAY_SIZE];
> > ^
> > /usr/include/cdio/iso9660.h:424:20: note: next member 'char
> > iso9660_svd_s::root_directory_filename' declared here
> > char root_directory_filename; /**< Is '\\0' or root
> > ^~~~~~~~~~~~~~~~~~~~~~~
> > /usr/include/cdio/iso9660.h:392:8: note: in the definition of 'struct
> > iso9660_svd_s'
> > struct iso9660_svd_s {
> > ^~~~~~~~~~~~~
this seems to be fixed in libcdio 0.92 in experimental, so maybe it's
time to upload that (or current 0.94 even?) to unstable?
Alternatively, 0.83-4.3 seems to build all right with the following,
slightly amended commit from upstream git (soname bump?):
commit 0bdb015d47b95abaa79fc2b83ffacdd63429a992
Author: R. Bernstein <[email protected]>
Date: Sat Mar 3 11:38:44 2012 -0500
pbatard empty array changes for iso9660.h. I think the last of the header
patches.
--- a/include/cdio/iso9660.h
+++ b/include/cdio/iso9660.h
@@ -60,7 +60,7 @@
typedef char achar_t; /*! See section 7.4.1 */
typedef char dchar_t; /*! See section 7.4.1 */
-#ifndef EMPTY_ARRAY_SIZE
+#ifndef EMPTY_ARRAY_SIZE
#define EMPTY_ARRAY_SIZE 0
#endif
@@ -273,8 +273,18 @@
the Extent described by this
Directory Record is
recorded. (9.1.9) */
- iso711_t filename_len; /*! number of bytes in filename field */
- char filename[EMPTY_ARRAY_SIZE];
+/*! MSVC compilers cannot handle a zero sized array in the middle
+ of a struct, and iso9660_dir_s is reused within iso9660_pvd_s.
+ Therefore, instead of defining:
+ iso711_t filename_len;
+ char filename[];
+ we leverage the fact that iso711_t and char are the same size
+ and use an union. The only gotcha is that the actual string
+ payload of filename.str[] starts at 1, not 0. */
+ union {
+ iso711_t len;
+ char str[1];
+ } filename;
} GNUC_PACKED;
/*!
@@ -976,7 +986,7 @@
uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
-#if FIXME
+#ifdef FIXME
uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
--- a/lib/iso9660/iso9660.c
+++ b/lib/iso9660/iso9660.c
@@ -301,7 +301,7 @@
*/
void
iso9660_set_dtime_with_timezone (const struct tm *p_tm,
- int timezone,
+ int time_zone,
/*out*/ iso9660_dtime_t *p_idr_date)
{
memset (p_idr_date, 0, 7);
@@ -317,7 +317,7 @@
/* The ISO 9660 timezone is in the range -48..+52 and each unit
represents a 15-minute interval. */
- p_idr_date->dt_gmtoff = timezone / 15;
+ p_idr_date->dt_gmtoff = time_zone / 15;
if (p_idr_date->dt_gmtoff < -48 ) {
@@ -337,16 +337,16 @@
void
iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date)
{
- int timezone = 0;
+ int time_zone = 0;
if (p_tm) {
#ifdef HAVE_TM_GMTOFF
/* Convert seconds to minutes */
- timezone = p_tm->tm_gmtoff / 60;
+ time_zone = p_tm->tm_gmtoff / 60;
#else
- timezone = (p_tm->tm_isdst > 0) ? -60 : 0;
+ time_zone = (p_tm->tm_isdst > 0) ? -60 : 0;
#endif
}
- iso9660_set_dtime_with_timezone (p_tm, timezone, p_idr_date);
+ iso9660_set_dtime_with_timezone (p_tm, time_zone, p_idr_date);
}
/*!
@@ -356,7 +356,7 @@
*/
void
iso9660_set_ltime_with_timezone (const struct tm *p_tm,
- int timezone,
+ int time_zone,
/*out*/ iso9660_ltime_t *pvd_date)
{
char *_pvd_date = (char *) pvd_date;
@@ -373,7 +373,7 @@
0 /* 1/100 secs */ );
/* Set time zone in 15-minute interval encoding. */
- pvd_date->lt_gmtoff -= (timezone / 15);
+ pvd_date->lt_gmtoff -= (time_zone / 15);
if (pvd_date->lt_gmtoff < -48 ) {
cdio_warn ("Converted ISO 9660 timezone %d is less than -48. Adjusted",
@@ -392,16 +392,16 @@
void
iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date)
{
- int timezone = 0;
+ int time_zone = 0;
if (p_tm) {
#ifdef HAVE_TM_GMTOFF
/* Set time zone in 15-minute interval encoding. */
- timezone = p_tm->tm_gmtoff / 60;
+ time_zone = p_tm->tm_gmtoff / 60;
#else
- timezone = (p_tm->tm_isdst > 0) ? -60 : 0;
+ time_zone = (p_tm->tm_isdst > 0) ? -60 : 0;
#endif
}
- iso9660_set_ltime_with_timezone (p_tm, timezone, pvd_date);
+ iso9660_set_ltime_with_timezone (p_tm, time_zone, pvd_date);
}
/*!
@@ -775,10 +775,10 @@
idr->volume_sequence_number = to_723(1);
- idr->filename_len = to_711(strlen(filename)
+ idr->filename.len = to_711(strlen(filename)
? strlen(filename) : 1); /* working hack! */
- memcpy(idr->filename, filename, from_711(idr->filename_len));
+ memcpy(&idr->filename.str[1], filename, from_711(idr->filename.len));
memcpy(&dir8[offset] + su_offset, su_data, su_size);
}
@@ -1130,7 +1130,7 @@
return strdup(strip_trail(p_pvd->application_id, ISO_MAX_APPLICATION_ID));
}
-#if FIXME
+#ifdef FIXME
lsn_t
iso9660_get_dir_extent(const iso9660_dir_t *idr)
{
@@ -1146,7 +1146,7 @@
return idr->length;
}
-#if FIXME
+#ifdef FIXME
uint8_t
iso9660_get_dir_size(const iso9660_dir_t *idr)
{
--- a/lib/iso9660/iso9660_fs.c
+++ b/lib/iso9660/iso9660_fs.c
@@ -107,12 +107,10 @@
frame and a header.
*/
if (CDIO_CD_FRAMESIZE_RAW == p_iso->i_framesize) {
- const int pre_user_data=CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE
- + CDIO_CD_SUBHEADER_SIZE;
- char buf[pre_user_data];
-
- i_byte_offset -= pre_user_data;
-
+ char buf[CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE + CDIO_CD_SUBHEADER_SIZE];
+
+ i_byte_offset -= CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE +
CDIO_CD_SUBHEADER_SIZE;
+
if ( DRIVER_OP_SUCCESS != cdio_stream_seek (p_iso->stream, i_byte_offset,
SEEK_SET) )
return;
@@ -739,7 +737,7 @@
if (!dir_len) return NULL;
- i_fname = from_711(p_iso9660_dir->filename_len);
+ i_fname = from_711(p_iso9660_dir->filename.len);
/* .. string in statbuf is one longer than in p_iso9660_dir's listing '\1' */
stat_len = sizeof(iso9660_stat_t)+i_fname+2;
@@ -775,7 +773,7 @@
calloc(1, sizeof(iso9660_stat_t)+i_rr_fname+2);
if (!p_stat_new)
{
- cdio_warn("Couldn't calloc(1, %zd)",
sizeof(iso9660_stat_t)+i_rr_fname+2);
+ cdio_warn("Couldn't calloc(1, %d)",
(int)sizeof(iso9660_stat_t)+i_rr_fname+2);
return NULL;
}
memcpy(p_stat_new, p_stat, stat_len);
@@ -784,15 +782,15 @@
}
strncpy(p_stat->filename, rr_fname, i_rr_fname+1);
} else {
- if ('\0' == p_iso9660_dir->filename[0] && 1 == i_fname)
+ if ('\0' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
strncpy (p_stat->filename, ".", sizeof("."));
- else if ('\1' == p_iso9660_dir->filename[0] && 1 == i_fname)
+ else if ('\1' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
strncpy (p_stat->filename, "..", sizeof(".."));
#ifdef HAVE_JOLIET
else if (i_joliet_level) {
int i_inlen = i_fname;
cdio_utf8_t *p_psz_out = NULL;
- if (cdio_charset_to_utf8(p_iso9660_dir->filename, i_inlen,
+ if (cdio_charset_to_utf8(&p_iso9660_dir->filename.str[1], i_inlen,
&p_psz_out, "UCS-2BE")) {
strncpy(p_stat->filename, p_psz_out, i_fname);
free(p_psz_out);
@@ -804,7 +802,7 @@
}
#endif /*HAVE_JOLIET*/
else {
- strncpy (p_stat->filename, p_iso9660_dir->filename, i_fname);
+ strncpy (p_stat->filename, &p_iso9660_dir->filename.str[1], i_fname);
}
}
}
@@ -878,12 +876,12 @@
/* (iso9660_dir->file_flags & ISO_DIRECTORY) */
- if (iso9660_dir->filename[0] == '\0')
+ if (iso9660_dir->filename.str[1] == '\0')
return strdup(".");
- else if (iso9660_dir->filename[0] == '\1')
+ else if (iso9660_dir->filename.str[1] == '\1')
return strdup("..");
else {
- return strdup(iso9660_dir->filename);
+ return strdup(&iso9660_dir->filename.str[1]);
}
}
@@ -982,13 +980,6 @@
cdio_assert (_root->type == _STAT_DIR);
- if (_root->size != ISO_BLOCKSIZE * _root->secsize)
- {
- cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!",
- (unsigned) _root->size,
- (unsigned long int) ISO_BLOCKSIZE * _root->secsize);
- }
-
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
@@ -1003,7 +994,7 @@
while (offset < (_root->secsize * ISO_BLOCKSIZE))
{
iso9660_dir_t *p_iso9660_dir = (void *) &_dirbuf[offset];
- iso9660_stat_t *p_stat;
+ iso9660_stat_t *p_iso9660_stat;
int cmp;
if (!iso9660_get_dir_len(p_iso9660_dir))
@@ -1012,27 +1003,26 @@
continue;
}
- p_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, dunno,
+ p_iso9660_stat = _iso9660_dir_to_statbuf (p_iso9660_dir, dunno,
p_env->i_joliet_level);
- cmp = strcmp(splitpath[0], p_stat->filename);
+ cmp = strcmp(splitpath[0], p_iso9660_stat->filename);
if ( 0 != cmp && 0 == p_env->i_joliet_level
- && yep != p_stat->rr.b3_rock ) {
+ && yep != p_iso9660_stat->rr.b3_rock ) {
char *trans_fname = NULL;
- unsigned int i_trans_fname=strlen(p_stat->filename);
- int trans_len;
+ unsigned int i_trans_fname=strlen(p_iso9660_stat->filename);
if (i_trans_fname) {
trans_fname = calloc(1, i_trans_fname+1);
if (!trans_fname) {
cdio_warn("can't allocate %lu bytes",
- (long unsigned int) strlen(p_stat->filename));
- free(p_stat);
+ (long unsigned int) strlen(p_iso9660_stat->filename));
+ free(p_iso9660_stat);
return NULL;
}
- trans_len = iso9660_name_translate_ext(p_stat->filename, trans_fname,
- p_env->i_joliet_level);
+ iso9660_name_translate_ext(p_iso9660_stat->filename, trans_fname,
+ p_env->i_joliet_level);
cmp = strcmp(splitpath[0], trans_fname);
free(trans_fname);
}
@@ -1040,15 +1030,15 @@
if (!cmp) {
iso9660_stat_t *ret_stat
- = _fs_stat_traverse (p_cdio, p_stat, &splitpath[1]);
- free(p_stat->rr.psz_symlink);
- free(p_stat);
+ = _fs_stat_traverse (p_cdio, p_iso9660_stat, &splitpath[1]);
+ free(p_iso9660_stat->rr.psz_symlink);
+ free(p_iso9660_stat);
free (_dirbuf);
return ret_stat;
}
- free(p_stat->rr.psz_symlink);
- free(p_stat);
+ free(p_iso9660_stat->rr.psz_symlink);
+ free(p_iso9660_stat);
offset += iso9660_get_dir_len(p_iso9660_dir);
}
@@ -1090,13 +1080,6 @@
cdio_assert (_root->type == _STAT_DIR);
- if (_root->size != ISO_BLOCKSIZE * _root->secsize)
- {
- cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!",
- (unsigned) _root->size,
- (unsigned long int) ISO_BLOCKSIZE * _root->secsize);
- }
-
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
@@ -1128,7 +1111,6 @@
&& yep != p_stat->rr.b3_rock ) {
char *trans_fname = NULL;
unsigned int i_trans_fname=strlen(p_stat->filename);
- int trans_len;
if (i_trans_fname) {
trans_fname = calloc(1, i_trans_fname+1);
@@ -1138,8 +1120,8 @@
free(p_stat);
return NULL;
}
- trans_len = iso9660_name_translate_ext(p_stat->filename, trans_fname,
- p_iso->i_joliet_level);
+ iso9660_name_translate_ext(p_stat->filename, trans_fname,
+ p_iso->i_joliet_level);
cmp = strcmp(splitpath[0], trans_fname);
free(trans_fname);
}
@@ -1304,13 +1286,6 @@
uint8_t *_dirbuf = NULL;
CdioList_t *retval = _cdio_list_new ();
- if (p_stat->size != ISO_BLOCKSIZE * p_stat->secsize)
- {
- cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!",
- (unsigned) p_stat->size,
- (unsigned long int) ISO_BLOCKSIZE * p_stat->secsize);
- }
-
_dirbuf = calloc(1, p_stat->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
@@ -1375,13 +1350,6 @@
uint8_t *_dirbuf = NULL;
CdioList_t *retval = _cdio_list_new ();
- if (p_stat->size != ISO_BLOCKSIZE * p_stat->secsize)
- {
- cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!",
- (unsigned int) p_stat->size,
- (unsigned long int) ISO_BLOCKSIZE * p_stat->secsize);
- }
-
_dirbuf = calloc(1, p_stat->secsize * ISO_BLOCKSIZE);
if (!_dirbuf)
{
@@ -1445,7 +1413,7 @@
{
iso9660_stat_t *statbuf = _cdio_list_node_data (entnode);
const char *psz_filename = (char *) statbuf->filename;
- const unsigned int len = strlen(psz_path) + strlen(psz_filename)+2;
+ unsigned int len = strlen(psz_path) + strlen(psz_filename)+2;
if (*ppsz_full_filename != NULL) free(*ppsz_full_filename);
*ppsz_full_filename = calloc(1, len);