From 183ed6cc5aa8d9fde05eb56ec680351fdc68449a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 18 Mar 2009 10:27:28 +0100 Subject: [PATCH] Made read_aaip_AA() safe against eventual Apple ISO AA fields --- libisofs/fs_image.c | 5 +++++ libisofs/rockridge.h | 5 +++++ libisofs/rockridge_read.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index cb392eb..b8b3dd5 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -1332,6 +1332,11 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent, continue; } + /* >>> AAIP-2 : + SUSP_SIG(sue, 'A', 'L') + read_aaip_AL() like read_aaip_AA() + */ + /* This message is inflationary */ /* } else { diff --git a/libisofs/rockridge.h b/libisofs/rockridge.h index 9af8a13..aec4c1c 100644 --- a/libisofs/rockridge.h +++ b/libisofs/rockridge.h @@ -125,6 +125,9 @@ struct rr_AA { }; +/* >>> AAIP-2 : struct rr_AL like struct rr_AA */ + + /** * Struct for a SUSP System User Entry (SUSP, 4.1) */ @@ -145,6 +148,8 @@ struct susp_sys_user_entry struct rr_SL SL; struct rr_AA AA; + /* >>> AAIP-2 : struct rr_AL */ + } data; /* 5 to 4+len_sue */ }; diff --git a/libisofs/rockridge_read.c b/libisofs/rockridge_read.c index b272ca3..1ab5a0d 100644 --- a/libisofs/rockridge_read.c +++ b/libisofs/rockridge_read.c @@ -442,15 +442,40 @@ int read_aaip_AA(struct susp_sys_user_entry *sue, unsigned char *aapt; if (*is_done) { + + /* AAIP-2 + To coexist with Apple ISO : + Gracefully react on eventually trailing Apple AA + */ + if (sue->version[0] != 1 || sue->len_sue[0] == 7) + return ISO_SUCCESS; + return ISO_WRONG_RR; } + /* Eventually create or grow storage */ if (*aa_size == 0 || *aa_string == NULL) { + + /* AAIP-2 + Gracefully react on eventually leading Apple AA + */ + if (sue->version[0] != 1 || sue->len_sue[0] < 9) { + return ISO_SUCCESS; + } + *aa_size = *aa_len + sue->len_sue[0]; *aa_string = calloc(*aa_size, 1); *aa_len = 0; } else if (*aa_len + sue->len_sue[0] > *aa_size) { + + if (sue->version[0] != 1) { + /* AAIP-2 + Apple ISO within the AAIP field group is not AAIP compliant + */ + return ISO_WRONG_RR; + } + *aa_size += *aa_len + sue->len_sue[0]; *aa_string = realloc(*aa_string, *aa_size); } @@ -466,8 +491,13 @@ int read_aaip_AA(struct susp_sys_user_entry *sue, /* Compose new SUSP header with signature aa[], cont == 0 */ aapt = *aa_string + *aa_len; + + /* >>> AAIP-2 + Change to new signature (AL ?) + */ aapt[0] = 'A'; aapt[1] = 'A'; + aapt[2] = sue->len_sue[0]; aapt[3] = 1; aapt[4] = 0; @@ -480,3 +510,7 @@ int read_aaip_AA(struct susp_sys_user_entry *sue, return ISO_SUCCESS; } +/* >>> AAIP-2 + read_aaip_AL() like read_aaip_AA() + */ +