[iso] fix libcio processing of Rock Ridge CE fields

* Boy do you not want to use chars in struct iso_su_ce_s as
  from_733() will sign extend the bytes and you will end up
  with an offset like 0xffffffc4 instead of 0x000000c4...
* Addresses the leftover from 6c44dccc10.
* Also some headers clean up and pick up latest libcdio changes.
This commit is contained in:
Pete Batard 2023-02-28 18:26:13 +00:00
parent 6c44dccc10
commit cb561e7176
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
3 changed files with 60 additions and 49 deletions

View file

@ -98,23 +98,23 @@ PRAGMA_BEGIN_PACKED
/*! system-use-sharing protocol */ /*! system-use-sharing protocol */
typedef struct iso_su_sp_s{ typedef struct iso_su_sp_s{
unsigned char magic[2]; uint8_t magic[2];
uint8_t skip; uint8_t skip;
} GNUC_PACKED iso_su_sp_t; } GNUC_PACKED iso_su_sp_t;
/*! system-use extension record */ /*! system-use extension record */
typedef struct iso_su_er_s { typedef struct iso_su_er_s {
iso711_t len_id; /**< Identifier length. Value 10?. */ iso711_t len_id; /**< Identifier length. Value 10?. */
unsigned char len_des; uint8_t len_des;
unsigned char len_src; uint8_t len_src;
iso711_t ext_ver; /**< Extension version. Value 1? */ iso711_t ext_ver; /**< Extension version. Value 1? */
char data[EMPTY_ARRAY_SIZE]; char data[EMPTY_ARRAY_SIZE];
} GNUC_PACKED iso_su_er_t; } GNUC_PACKED iso_su_er_t;
typedef struct iso_su_ce_s { typedef struct iso_su_ce_s {
char extent[8]; uint8_t extent[8];
char offset[8]; uint8_t offset[8];
char size[8]; uint8_t size[8];
} iso_su_ce_t; } iso_su_ce_t;
/*! POSIX file attributes, PX. See Rock Ridge Section 4.1.2 */ /*! POSIX file attributes, PX. See Rock Ridge Section 4.1.2 */
@ -165,7 +165,7 @@ typedef struct iso_rock_sl_part_s {
/*! Symbolic link. See Rock Ridge Section 4.1.3 */ /*! Symbolic link. See Rock Ridge Section 4.1.3 */
typedef struct iso_rock_sl_s { typedef struct iso_rock_sl_s {
unsigned char flags; uint8_t flags;
iso_rock_sl_part_t link; iso_rock_sl_part_t link;
} GNUC_PACKED iso_rock_sl_t ; } GNUC_PACKED iso_rock_sl_t ;
@ -184,7 +184,7 @@ typedef enum {
typedef struct iso_rock_nm_s { typedef struct iso_rock_nm_s {
unsigned char flags; uint8_t flags;
char name[EMPTY_ARRAY_SIZE]; char name[EMPTY_ARRAY_SIZE];
} GNUC_PACKED iso_rock_nm_t ; } GNUC_PACKED iso_rock_nm_t ;

View file

@ -1,6 +1,6 @@
/* /*
Copyright (C) 2020 Pete Batard <pete@akeo.ie> Copyright (C) 2020, 2023 Pete Batard <pete@akeo.ie>
Copyright (C) 2005, 2008, 2010-2011, 2014, 2017 Rocky Bernstein Copyright (C) 2005, 2008, 2010-2011, 2014, 2017, 2022 Rocky Bernstein
<rocky@gnu.org> <rocky@gnu.org>
Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale
@ -94,34 +94,36 @@ realloc_symlink(/*in/out*/ iso9660_stat_t *p_stat, uint8_t i_grow)
/* This is a way of ensuring that we have something in the system /* This is a way of ensuring that we have something in the system
use fields that is compatible with Rock Ridge */ use fields that is compatible with Rock Ridge */
#define CHECK_SP(FAIL) \ #define CHECK_SP(FAIL) \
if(rr->u.SP.magic[0] != 0xbe) FAIL; \ if (rr->u.SP.magic[0] != 0xbe) FAIL; \
if(rr->u.SP.magic[1] != 0xef) FAIL; \ if (rr->u.SP.magic[1] != 0xef) FAIL; \
p_stat->rr.s_rock_offset = rr->u.SP.skip; p_stat->rr.s_rock_offset = rr->u.SP.skip;
/* We define a series of macros because each function must do exactly the /* We define a series of macros because each function must do exactly the
same thing in certain places. We use the macros to ensure that everything same thing in certain places. We use the macros to ensure that everything
is done correctly */ is done correctly */
#define CONTINUE_DECLS \ #define CONTINUE_DECLS \
int cont_extent = 0, cont_offset = 0, cont_size = 0; \ uint32_t cont_extent = 0, cont_offset = 0, cont_size = 0; \
void *buffer = NULL uint8_t *buffer = NULL
#define CHECK_CE \ #define CHECK_CE(FAIL) \
{ cont_extent = from_733(*rr->u.CE.extent); \ { cont_extent = from_733(*rr->u.CE.extent); \
cont_offset = from_733(*rr->u.CE.offset); \ cont_offset = from_733(*rr->u.CE.offset); \
cont_size = from_733(*rr->u.CE.size); \ if (cont_offset >= ISO_BLOCKSIZE) FAIL; \
(void)cont_extent; (void)cont_offset, (void)cont_size; } cont_size = from_733(*rr->u.CE.size); \
if (cont_size >= ISO_BLOCKSIZE) FAIL; \
}
#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; \
if (0xff != p_stat->rr.s_rock_offset) \ if (0xff != p_stat->rr.s_rock_offset) \
{ \ { \
LEN -= p_stat->rr.s_rock_offset; \ LEN -= p_stat->rr.s_rock_offset; \
CHR += p_stat->rr.s_rock_offset; \ CHR += p_stat->rr.s_rock_offset; \
if (LEN<0) LEN=0; \ if (LEN<0) LEN=0; \
} \ } \
} }
@ -130,22 +132,22 @@ realloc_symlink(/*in/out*/ iso9660_stat_t *p_stat, uint8_t i_grow)
the specified field of a iso_rock_statbuf_t. the specified field of a iso_rock_statbuf_t.
non-paramater variables are p_stat, rr, and cnt. non-paramater variables are p_stat, rr, and cnt.
*/ */
#define add_time(FLAG, TIME_FIELD) \ #define add_time(FLAG, TIME_FIELD) \
if (rr->u.TF.flags & FLAG) { \ if (rr->u.TF.flags & FLAG) { \
p_stat->rr.TIME_FIELD.b_used = true; \ p_stat->rr.TIME_FIELD.b_used = true; \
p_stat->rr.TIME_FIELD.b_longdate = \ p_stat->rr.TIME_FIELD.b_longdate = \
(0 != (rr->u.TF.flags & ISO_ROCK_TF_LONG_FORM)); \ (0 != (rr->u.TF.flags & ISO_ROCK_TF_LONG_FORM)); \
if (p_stat->rr.TIME_FIELD.b_longdate) { \ if (p_stat->rr.TIME_FIELD.b_longdate) { \
memcpy(&(p_stat->rr.TIME_FIELD.t.ltime), \ memcpy(&(p_stat->rr.TIME_FIELD.t.ltime), \
&(rr->u.TF.time_bytes[cnt]), \ &(rr->u.TF.time_bytes[cnt]), \
sizeof(iso9660_ltime_t)); \ sizeof(iso9660_ltime_t)); \
cnt += sizeof(iso9660_ltime_t); \ cnt += sizeof(iso9660_ltime_t); \
} else { \ } else { \
memcpy(&(p_stat->rr.TIME_FIELD.t.dtime), \ memcpy(&(p_stat->rr.TIME_FIELD.t.dtime), \
&(rr->u.TF.time_bytes[cnt]), \ &(rr->u.TF.time_bytes[cnt]), \
sizeof(iso9660_dtime_t)); \ sizeof(iso9660_dtime_t)); \
cnt += sizeof(iso9660_dtime_t); \ cnt += sizeof(iso9660_dtime_t); \
} \ } \
} }
/* Indicates if we should process deep directory entries */ /* Indicates if we should process deep directory entries */
@ -202,7 +204,7 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
switch(sig) { switch(sig) {
case SIG('S','P'): case SIG('S','P'):
CHECK_SP(goto out); CHECK_SP({cdio_warn("Invalid Rock Ridge SP field"); goto out;});
p_stat->rr.u_su_fields |= ISO_ROCK_SUF_SP; p_stat->rr.u_su_fields |= ISO_ROCK_SUF_SP;
break; break;
case SIG('C','E'): case SIG('C','E'):
@ -213,8 +215,17 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir,
if ('\1' == p_iso9660_dir->filename.str[1] && 1 == i_fname) if ('\1' == p_iso9660_dir->filename.str[1] && 1 == i_fname)
break; break;
} }
CHECK_CE; CHECK_CE({cdio_warn("Invalid Rock Ridge CE field"); goto out;});
p_stat->rr.u_su_fields |= ISO_ROCK_SUF_CE; p_stat->rr.u_su_fields |= ISO_ROCK_SUF_CE;
/* We may already be processing a continuation block so free it */
free(buffer);
buffer = calloc(1, ISO_BLOCKSIZE);
if (!buffer)
goto out;
if (iso9660_iso_seek_read(p_image, buffer, cont_extent, 1) != ISO_BLOCKSIZE)
goto out;
chr = &buffer[cont_offset];
len = cont_size;
break; break;
case SIG('E','R'): case SIG('E','R'):
cdio_debug("ISO 9660 Extensions: "); cdio_debug("ISO 9660 Extensions: ");
@ -471,7 +482,7 @@ iso9660_get_rock_attr_str(posix_mode_t st_mode)
result[ 8] = (st_mode & ISO_ROCK_IWOTH) ? 'w' : '-'; result[ 8] = (st_mode & ISO_ROCK_IWOTH) ? 'w' : '-';
result[ 9] = (st_mode & ISO_ROCK_IXOTH) ? 'x' : '-'; result[ 9] = (st_mode & ISO_ROCK_IXOTH) ? 'x' : '-';
result[11] = '\0'; result[10] = '\0';
return result; return result;
} }

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.22.1984" CAPTION "Rufus 3.22.1985"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,22,1984,0 FILEVERSION 3,22,1985,0
PRODUCTVERSION 3,22,1984,0 PRODUCTVERSION 3,22,1985,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.22.1984" VALUE "FileVersion", "3.22.1985"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.22.exe" VALUE "OriginalFilename", "rufus-3.22.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.22.1984" VALUE "ProductVersion", "3.22.1985"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"