[udf] workaround for zero sized arrays and MSVC

* sizeof(*(p_udf_dirent->fid) was erroneous in udf_readdir
  which prevented proper computation of ofs which prevented
  listing of directory content
* enforce a single zero sized array only at the end of a struct
This commit is contained in:
Pete Batard 2012-01-16 00:12:44 +00:00
parent d12268473d
commit 668e2d54f5
4 changed files with 21 additions and 28 deletions

View File

@ -54,14 +54,6 @@
#include <cdio/types.h>
/* What to put between the brackets for empty arrays */
#ifdef _MSC_VER
/* Very disputable hack! -- good thing we use MinGW for the release */
#define EMPTY_ARRAY_ECMA 1
#else
#define EMPTY_ARRAY_ECMA 0
#endif
/**
Imagine the below enum values as \#define'd values rather than
distinct values of an enum.
@ -507,9 +499,9 @@ struct logvol_integrity_desc_s
udf_Uint8_t logvol_contents_use[32];
udf_Uint32_t i_partitions;
udf_Uint32_t imp_use_len;
udf_Uint32_t freespace_table[EMPTY_ARRAY_ECMA];
udf_Uint32_t size_table[EMPTY_ARRAY_ECMA];
udf_Uint8_t imp_use[EMPTY_ARRAY_ECMA];
// udf_Uint32_t freespace_table[0];
// udf_Uint32_t size_table[0];
udf_Uint8_t imp_use[0];
} GNUC_PACKED;
/** Integrity Type (ECMA 167r3 3/10.10.3) */
@ -579,9 +571,9 @@ struct udf_fileid_desc_s
udf_Uint8_t i_file_id;
udf_long_ad_t icb;
udf_Uint16_t i_imp_use;
udf_Uint8_t imp_use[EMPTY_ARRAY_ECMA];
udf_Uint8_t file_id[EMPTY_ARRAY_ECMA];
udf_Uint8_t padding[EMPTY_ARRAY_ECMA];
udf_Uint8_t imp_use[0];
// udf_Uint8_t file_id[0];
// udf_Uint8_t padding[0];
} GNUC_PACKED;
typedef struct udf_fileid_desc_s udf_fileid_desc_t;
@ -735,8 +727,8 @@ struct udf_file_entry_s
udf_Uint64_t unique_ID;
udf_Uint32_t i_extended_attr;
udf_Uint32_t i_alloc_descs;
udf_Uint8_t ext_attr[EMPTY_ARRAY_ECMA];
udf_Uint8_t alloc_descs[EMPTY_ARRAY_ECMA];
// udf_Uint8_t ext_attr[0];
udf_Uint8_t ext_attr_alloc_descs[0];
} GNUC_PACKED;
typedef struct udf_file_entry_s udf_file_entry_t;
@ -993,8 +985,8 @@ struct extended_file_entry
udf_Uint64_t unique_ID;
udf_Uint32_t length_extended_attr;
udf_Uint32_t length_alloc_descs;
udf_Uint8_t ext_attr[EMPTY_ARRAY_ECMA];
udf_Uint8_t alloc_descs[EMPTY_ARRAY_ECMA];
// udf_Uint8_t ext_attr[0];
udf_Uint8_t ext_attr_alloc_descs[0];
} GNUC_PACKED;
PRAGMA_END_PACKED

View File

@ -34,7 +34,8 @@
#define CEILING(x, y) ((x+(y-1))/y)
#define GETICB(offset) \
&p_udf_fe->alloc_descs[offset]
&p_udf_fe->ext_attr_alloc_descs[offset]
// TODO: do we need to add p_udf_fe->i_extended_attr to offset here?
const char *
udf_get_filename(const udf_dirent_t *p_udf_dirent)

View File

@ -161,7 +161,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->ext_attr + p_udf_fe->i_extended_attr);
(p_udf_fe->ext_attr_alloc_descs + p_udf_fe->i_extended_attr);
*start = uint32_from_le(p_ad->pos);
*end = *start +
@ -173,7 +173,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->ext_attr + p_udf_fe->i_extended_attr);
(p_udf_fe->ext_attr_alloc_descs + p_udf_fe->i_extended_attr);
*start = uint32_from_le(p_ad->loc.lba); /* ignore partition number */
*end = *start +
@ -184,7 +184,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->ext_attr + p_udf_fe->i_extended_attr);
(p_udf_fe->ext_attr_alloc_descs + p_udf_fe->i_extended_attr);
*start = uint32_from_le(p_ad->ext_loc.lba); /* ignore partition number */
*end = *start +

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.0.7.127"
CAPTION "Rufus v1.0.7.128"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
@ -70,7 +70,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.0.7 (Build 127)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.0.7 (Build 128)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -208,8 +208,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,7,127
PRODUCTVERSION 1,0,7,127
FILEVERSION 1,0,7,128
PRODUCTVERSION 1,0,7,128
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -226,13 +226,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.7.127"
VALUE "FileVersion", "1.0.7.128"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.7.127"
VALUE "ProductVersion", "1.0.7.128"
END
END
BLOCK "VarFileInfo"