"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libisofs/rockridge_read.c" between
xorriso-1.4.6.tar.gz and xorriso-1.4.8.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

rockridge_read.c  (xorriso-1.4.6):rockridge_read.c  (xorriso-1.4.8)
skipping to change at line 38 skipping to change at line 38
#include <string.h> #include <string.h>
struct susp_iterator struct susp_iterator
{ {
uint8_t* base; uint8_t* base;
int pos; int pos;
int size; int size;
IsoDataSource *src; IsoDataSource *src;
int msgid; int msgid;
/* Number of blocks in the ISO 9660 filesystem */
uint32_t fs_blocks;
/* block and offset for next continuation area */ /* block and offset for next continuation area */
uint32_t ce_block; uint32_t ce_block;
uint32_t ce_off; uint32_t ce_off;
/** Length of the next continuation area, 0 if no more CA are specified */ /** Length of the next continuation area, 0 if no more CA are specified */
uint32_t ce_len; uint32_t ce_len;
uint8_t *buffer; /*< If there are continuation areas */ uint8_t *buffer; /*< If there are continuation areas */
}; };
SuspIterator* SuspIterator*
susp_iter_new(IsoDataSource *src, struct ecma119_dir_record *record, susp_iter_new(IsoDataSource *src, struct ecma119_dir_record *record,
uint8_t len_skp, int msgid) uint32_t fs_blocks, uint8_t len_skp, int msgid)
{ {
int pad = (record->len_fi[0] + 1) % 2; int pad = (record->len_fi[0] + 1) % 2;
struct susp_iterator *iter = malloc(sizeof(struct susp_iterator)); struct susp_iterator *iter = malloc(sizeof(struct susp_iterator));
if (iter == NULL) { if (iter == NULL) {
return NULL; return NULL;
} }
iter->base = record->file_id + record->len_fi[0] + pad; iter->base = record->file_id + record->len_fi[0] + pad;
iter->pos = len_skp; /* 0 in most cases */ iter->pos = len_skp; /* 0 in most cases */
iter->size = record->len_dr[0] - record->len_fi[0] - 33 - pad; iter->size = record->len_dr[0] - record->len_fi[0] - 33 - pad;
iter->src = src; iter->src = src;
iter->msgid = msgid; iter->msgid = msgid;
iter->fs_blocks = fs_blocks;
iter->ce_len = 0; iter->ce_len = 0;
iter->buffer = NULL; iter->buffer = NULL;
return iter; return iter;
} }
int susp_iter_next(SuspIterator *iter, struct susp_sys_user_entry **sue) /* More than 1 MiB in a single file's CE area is suspicious */
#define ISO_SUSP_MAX_CE_BYTES (1024 * 1024)
/* @param flag bit0 = First call on root:
Not yet clear whether this is SUSP at all
*/
int susp_iter_next(SuspIterator *iter, struct susp_sys_user_entry **sue,
int flag)
{ {
struct susp_sys_user_entry *entry; struct susp_sys_user_entry *entry;
entry = (struct susp_sys_user_entry*)(iter->base + iter->pos); entry = (struct susp_sys_user_entry*)(iter->base + iter->pos);
if (flag & 1) {
/* Yet unclear whether it is SUSP at all */
if (iter->size < 7)
return 0;
if (!SUSP_SIG(entry, 'S', 'P'))
return 0;
if (entry->len_sue[0] < 7)
return 0;
/* Looks like SUSP enough to pass the further processing here. */
}
if ( (iter->pos + 4 > iter->size) || (SUSP_SIG(entry, 'S', 'T'))) { if ( (iter->pos + 4 > iter->size) || (SUSP_SIG(entry, 'S', 'T'))) {
/* /*
* End of the System Use Area or Continuation Area. * End of the System Use Area or Continuation Area.
* Note that ST is not needed when the space left is less than 4. * Note that ST is not needed when the space left is less than 4.
* (IEEE 1281, SUSP. section 4) * (IEEE 1281, SUSP. section 4)
*/ */
if (iter->ce_len) { if (iter->ce_len) {
uint32_t block, nblocks; uint32_t block, nblocks, skipped_blocks, skipped_bytes;
/* A CE has found, there is another continuation area */ /* A CE was found, there is another continuation area */
nblocks = DIV_UP(iter->ce_off + iter->ce_len, BLOCK_SIZE); skipped_blocks = iter->ce_off / BLOCK_SIZE;
skipped_bytes = skipped_blocks * BLOCK_SIZE;
nblocks = DIV_UP(iter->ce_off - skipped_bytes + iter->ce_len,
BLOCK_SIZE);
if (nblocks <= 0 || iter->ce_len > ISO_SUSP_MAX_CE_BYTES)
return ISO_SUSP_WRONG_CE_SIZE;
if (((uint64_t) iter->ce_block) + skipped_blocks + nblocks >
(uint64_t) iter->fs_blocks)
return ISO_SUSP_WRONG_CE_SIZE;
iter->buffer = realloc(iter->buffer, nblocks * BLOCK_SIZE); iter->buffer = realloc(iter->buffer, nblocks * BLOCK_SIZE);
/* read all blocks needed to cache the full CE */ /* Read blocks needed to cache the given CE area range */
for (block = 0; block < nblocks; ++block) { for (block = 0; block < nblocks; ++block) {
int ret; int ret;
ret = iter->src->read_block(iter->src, iter->ce_block + block, ret = iter->src->read_block(iter->src,
iter->buffer + block * BLOCK_SIZE); iter->ce_block + skipped_blocks + block,
iter->buffer + block * BLOCK_SIZE);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
} }
iter->base = iter->buffer + iter->ce_off; iter->base = iter->buffer + (iter->ce_off - skipped_bytes);
iter->pos = 0; iter->pos = 0;
iter->size = iter->ce_len; iter->size = iter->ce_len;
iter->ce_len = 0; iter->ce_len = 0;
entry = (struct susp_sys_user_entry*)iter->base; entry = (struct susp_sys_user_entry*)iter->base;
} else { } else {
return 0; return 0;
} }
} }
if (entry->len_sue[0] == 0) { if (entry->len_sue[0] == 0) {
skipping to change at line 137 skipping to change at line 167
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
} else { } else {
iter->ce_block = iso_read_bb(entry->data.CE.block, 4, NULL); iter->ce_block = iso_read_bb(entry->data.CE.block, 4, NULL);
iter->ce_off = iso_read_bb(entry->data.CE.offset, 4, NULL); iter->ce_off = iso_read_bb(entry->data.CE.offset, 4, NULL);
iter->ce_len = iso_read_bb(entry->data.CE.len, 4, NULL); iter->ce_len = iso_read_bb(entry->data.CE.len, 4, NULL);
} }
/* we don't want to return CE entry to the user */ /* we don't want to return CE entry to the user */
return susp_iter_next(iter, sue); return susp_iter_next(iter, sue, 0);
} else if (SUSP_SIG(entry, 'P', 'D')) { } else if (SUSP_SIG(entry, 'P', 'D')) {
/* skip padding */ /* skip padding */
return susp_iter_next(iter, sue); return susp_iter_next(iter, sue, 0);
} }
*sue = entry; *sue = entry;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
void susp_iter_free(SuspIterator *iter) void susp_iter_free(SuspIterator *iter)
{ {
free(iter->buffer); free(iter->buffer);
free(iter); free(iter);
skipping to change at line 377 skipping to change at line 407
/* unsupported flag component */ /* unsupported flag component */
return ISO_UNSUPPORTED_RR; return ISO_UNSUPPORTED_RR;
} else { } else {
len = sl->data.SL.comps[pos + 1]; len = sl->data.SL.comps[pos + 1];
comp = (char*)&sl->data.SL.comps[pos + 2]; comp = (char*)&sl->data.SL.comps[pos + 2];
} }
if (*cont == 1) { if (*cont == 1) {
/* new component */ /* new component */
size_t size = strlen(*dest); size_t size = strlen(*dest);
int has_slash;
*dest = realloc(*dest, strlen(*dest) + len + 2); *dest = realloc(*dest, strlen(*dest) + len + 2);
if (*dest == NULL) { if (*dest == NULL) {
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
} }
/* it is a new compoenent, add the '/' */ /* it is a new compoenent, add the '/' */
if ((*dest)[size-1] != '/') { has_slash = 0;
if (size > 0)
if ((*dest)[size - 1] == '/')
has_slash = 1;
if (!has_slash) {
(*dest)[size] = '/'; (*dest)[size] = '/';
(*dest)[size+1] = '\0'; (*dest)[size+1] = '\0';
} }
strncat(*dest, comp, len); strncat(*dest, comp, len);
} else if (*cont == 2) { } else if (*cont == 2) {
/* the component continues */ /* the component continues */
*dest = realloc(*dest, strlen(*dest) + len + 1); *dest = realloc(*dest, strlen(*dest) + len + 1);
if (*dest == NULL) { if (*dest == NULL) {
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
} }
skipping to change at line 464 skipping to change at line 500
*/ */
int read_aaip_AA(struct susp_sys_user_entry *sue, int read_aaip_AA(struct susp_sys_user_entry *sue,
unsigned char **aa_string, size_t *aa_size, size_t *aa_len, unsigned char **aa_string, size_t *aa_size, size_t *aa_len,
size_t *prev_field, int *is_done, int flag) size_t *prev_field, int *is_done, int flag)
{ {
unsigned char *aapt; unsigned char *aapt;
if (*is_done) { if (*is_done) {
/* To coexist with Apple ISO : /* To coexist with Apple ISO :
Gracefully react on eventually trailing Apple AA Gracefully react on possibly trailing Apple AA
*/ */
if (sue->version[0] != 1 || sue->len_sue[0] == 7) if (sue->version[0] != 1 || sue->len_sue[0] == 7)
return ISO_SUCCESS; return ISO_SUCCESS;
return ISO_WRONG_RR; return ISO_WRONG_RR;
} }
/* Eventually create or grow storage */
if (*aa_size == 0 || *aa_string == NULL) { if (*aa_size == 0 || *aa_string == NULL) {
/* Gracefully react on possibly leading Apple AA
/* Gracefully react on eventually leading Apple AA
*/ */
if (sue->version[0] != 1 || sue->len_sue[0] < 9) { if (sue->version[0] != 1 || sue->len_sue[0] < 9)
return ISO_SUCCESS; return ISO_SUCCESS;
} }
/* A valid AAIP AA entry has 5 header bytes and at least 1 component byte
*/
if (sue->len_sue[0] < 6)
return ISO_WRONG_RR;
/* Possibly create or grow storage */
if (*aa_size == 0 || *aa_string == NULL) {
*aa_size = *aa_len + sue->len_sue[0]; *aa_size = *aa_len + sue->len_sue[0];
*aa_string = calloc(*aa_size, 1); *aa_string = calloc(*aa_size, 1);
*aa_len = 0; *aa_len = 0;
} else if (*aa_len + sue->len_sue[0] > *aa_size) { } else if (*aa_len + sue->len_sue[0] > *aa_size) {
if (sue->version[0] != 1) { if (sue->version[0] != 1) {
/* Apple ISO within the AAIP field group is not AAIP compliant /* Apple ISO within the AAIP field group is not AAIP compliant
*/ */
return ISO_WRONG_RR; return ISO_WRONG_RR;
} }
skipping to change at line 535 skipping to change at line 575
unsigned char **aa_string, size_t *aa_size, size_t *aa_len, unsigned char **aa_string, size_t *aa_size, size_t *aa_len,
size_t *prev_field, int *is_done, int flag) size_t *prev_field, int *is_done, int flag)
{ {
unsigned char *aapt; unsigned char *aapt;
if (*is_done) if (*is_done)
return ISO_WRONG_RR; return ISO_WRONG_RR;
if (sue->version[0] != 1) if (sue->version[0] != 1)
return ISO_WRONG_RR; return ISO_WRONG_RR;
/* Eventually create or grow storage */ /* A valid AL entry has 5 header bytes and at least 1 component byte
*/
if (sue->len_sue[0] < 6)
return ISO_WRONG_RR;
/* Possibly create or grow storage */
if (*aa_size == 0 || *aa_string == NULL) { if (*aa_size == 0 || *aa_string == NULL) {
*aa_size = *aa_len + sue->len_sue[0]; *aa_size = *aa_len + sue->len_sue[0];
*aa_string = calloc(*aa_size, 1); *aa_string = calloc(*aa_size, 1);
*aa_len = 0; *aa_len = 0;
} else if (*aa_len + sue->len_sue[0] > *aa_size) { } else if (*aa_len + sue->len_sue[0] > *aa_size) {
*aa_size += *aa_len + sue->len_sue[0]; *aa_size += *aa_len + sue->len_sue[0];
*aa_string = realloc(*aa_string, *aa_size); *aa_string = realloc(*aa_string, *aa_size);
} }
if (*aa_string == NULL) if (*aa_string == NULL)
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
 End of changes. 21 change blocks. 
20 lines changed or deleted 65 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)