mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[iso9660] workaround for zero sized filename array and MSVC
* use an union of iso711_t and char (same size), and and access the string starting at index 1
This commit is contained in:
parent
b0552a96b9
commit
4a63955e22
5 changed files with 34 additions and 21 deletions
|
@ -233,6 +233,20 @@ typedef struct iso9660_stat_s iso9660_stat_t;
|
||||||
|
|
||||||
#include <cdio/rock.h>
|
#include <cdio/rock.h>
|
||||||
|
|
||||||
|
/*! MSVC compilers cannot handle a zero sized array in the middle of a struct, and
|
||||||
|
uct iso9660_dir_s is reused in the middle of iso9660_pvd_s, so instead of having
|
||||||
|
iso711_t filename_len;
|
||||||
|
char filename[];
|
||||||
|
we use the fact that iso711_t and char are the same size and use an union.
|
||||||
|
The only gotcha is that the actual string payload starts at 1, not 0
|
||||||
|
*/
|
||||||
|
union iso9660_filename_u {
|
||||||
|
iso711_t len;
|
||||||
|
char str[1];
|
||||||
|
} GNUC_PACKED;
|
||||||
|
|
||||||
|
typedef union iso9660_filename_u iso9660_filename_t;
|
||||||
|
|
||||||
/*! \brief Format of an ISO-9660 directory record
|
/*! \brief Format of an ISO-9660 directory record
|
||||||
|
|
||||||
Section 9.1 of ECMA 119.
|
Section 9.1 of ECMA 119.
|
||||||
|
@ -273,8 +287,7 @@ struct iso9660_dir_s {
|
||||||
the Extent described by this
|
the Extent described by this
|
||||||
Directory Record is
|
Directory Record is
|
||||||
recorded. (9.1.9) */
|
recorded. (9.1.9) */
|
||||||
iso711_t filename_len; /*! number of bytes in filename field */
|
iso9660_filename_t filename;
|
||||||
char filename[EMPTY_ARRAY_SIZE];
|
|
||||||
} GNUC_PACKED;
|
} GNUC_PACKED;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -771,10 +771,10 @@ iso9660_dir_add_entry_su(void *dir,
|
||||||
|
|
||||||
idr->volume_sequence_number = to_723(1);
|
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! */
|
? 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);
|
memcpy(&dir8[offset] + su_offset, su_data, su_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -744,7 +744,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||||||
|
|
||||||
if (!dir_len) return NULL;
|
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' */
|
/* .. string in statbuf is one longer than in p_iso9660_dir's listing '\1' */
|
||||||
stat_len = sizeof(iso9660_stat_t)+i_fname+2;
|
stat_len = sizeof(iso9660_stat_t)+i_fname+2;
|
||||||
|
@ -789,9 +789,9 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||||||
}
|
}
|
||||||
strncpy(p_stat->filename, rr_fname, i_rr_fname+1);
|
strncpy(p_stat->filename, rr_fname, i_rr_fname+1);
|
||||||
} else {
|
} 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("."));
|
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(".."));
|
strncpy (p_stat->filename, "..", sizeof(".."));
|
||||||
#ifdef HAVE_JOLIET
|
#ifdef HAVE_JOLIET
|
||||||
else if (i_joliet_level) {
|
else if (i_joliet_level) {
|
||||||
|
@ -809,7 +809,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||||||
}
|
}
|
||||||
#endif /*HAVE_JOLIET*/
|
#endif /*HAVE_JOLIET*/
|
||||||
else {
|
else {
|
||||||
strncpy (p_stat->filename, p_iso9660_dir->filename, i_fname);
|
strncpy (p_stat->filename, &p_iso9660_dir->filename.str[1], i_fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -883,12 +883,12 @@ iso9660_dir_to_name (const iso9660_dir_t *iso9660_dir)
|
||||||
|
|
||||||
/* (iso9660_dir->file_flags & ISO_DIRECTORY) */
|
/* (iso9660_dir->file_flags & ISO_DIRECTORY) */
|
||||||
|
|
||||||
if (iso9660_dir->filename[0] == '\0')
|
if (iso9660_dir->filename.str[1] == '\0')
|
||||||
return _strdup(".");
|
return _strdup(".");
|
||||||
else if (iso9660_dir->filename[0] == '\1')
|
else if (iso9660_dir->filename.str[1] == '\1')
|
||||||
return _strdup("..");
|
return _strdup("..");
|
||||||
else {
|
else {
|
||||||
return _strdup(iso9660_dir->filename);
|
return _strdup(&iso9660_dir->filename.str[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ realloc_symlink(/*in/out*/ iso9660_stat_t *p_stat, uint8_t i_grow)
|
||||||
|
|
||||||
#define SETUP_ROCK_RIDGE(DE,CHR,LEN) \
|
#define SETUP_ROCK_RIDGE(DE,CHR,LEN) \
|
||||||
{ \
|
{ \
|
||||||
LEN= sizeof(iso9660_dir_t) + DE->filename_len; \
|
LEN= sizeof(iso9660_dir_t) + DE->filename.len; \
|
||||||
if(LEN & 1) LEN++; \
|
if(LEN & 1) LEN++; \
|
||||||
CHR = ((unsigned char *) DE) + LEN; \
|
CHR = ((unsigned char *) DE) + LEN; \
|
||||||
LEN = *((unsigned char *) DE) - LEN; \
|
LEN = *((unsigned char *) DE) - LEN; \
|
||||||
|
@ -194,10 +194,10 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
|
||||||
break;
|
break;
|
||||||
case SIG('C','E'):
|
case SIG('C','E'):
|
||||||
{
|
{
|
||||||
iso711_t i_fname = from_711(p_iso9660_dir->filename_len);
|
iso711_t i_fname = from_711(p_iso9660_dir->filename.len);
|
||||||
if ('\0' == p_iso9660_dir->filename[0] && 1 == i_fname)
|
if ('\0' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
|
||||||
break;
|
break;
|
||||||
if ('\1' == p_iso9660_dir->filename[0] && 1 == i_fname)
|
if ('\1' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CHECK_CE;
|
CHECK_CE;
|
||||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_APPWINDOW
|
EXSTYLE WS_EX_APPWINDOW
|
||||||
CAPTION "Rufus v1.0.7.131"
|
CAPTION "Rufus v1.0.7.132"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
||||||
|
@ -70,7 +70,7 @@ BEGIN
|
||||||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
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,
|
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||||
"SysLink",WS_TABSTOP,46,47,114,9
|
"SysLink",WS_TABSTOP,46,47,114,9
|
||||||
LTEXT "Version 1.0.7 (Build 131)",IDC_STATIC,46,19,78,8
|
LTEXT "Version 1.0.7 (Build 132)",IDC_STATIC,46,19,78,8
|
||||||
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
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
|
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
|
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||||
|
@ -208,8 +208,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,0,7,131
|
FILEVERSION 1,0,7,132
|
||||||
PRODUCTVERSION 1,0,7,131
|
PRODUCTVERSION 1,0,7,132
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -226,13 +226,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "akeo.ie"
|
VALUE "CompanyName", "akeo.ie"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "1.0.7.131"
|
VALUE "FileVersion", "1.0.7.132"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus.exe"
|
VALUE "OriginalFilename", "rufus.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "1.0.7.131"
|
VALUE "ProductVersion", "1.0.7.132"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue