diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 9dd1869..596ff86 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2006.10.08.095016" +#define Cdrskin_timestamP "2006.10.09.083438" diff --git a/libburn/asserts.txt b/libburn/asserts.txt index dbc17cd..2c4ca2f 100644 --- a/libburn/asserts.txt +++ b/libburn/asserts.txt @@ -591,16 +591,18 @@ ts A61008 ------------------------------------------------------------------------------ - 45) libburn/toc.c: assert(0); /* unhandled! find out ccd's +++ 45) libburn/toc.c: assert(0); /* unhandled! find out ccd's static write_clonecd2(): - defunct -, - unused - -=> ? mangle assert ? +=> mangle assert + +ts A61008 ------------------------------------------------------------------------------ - 46) libburn/toc.c: assert(d->busy); +++ 46) libburn/toc.c: assert(d->busy); toc_find_modes(): The drive to work on is not marked busy @@ -608,22 +610,26 @@ Called by mmc_read_toc() alias read_toc() by ... burn_drive_grab() : Severe Libburn Error => to be prevented on the higher levels -=> issue LIBDAX_MSGS_SEV_WARNING +=> delete assert + +ts A61008 ------------------------------------------------------------------------------ - 47) libburn/util.c: assert(s); +++ 47) libburn/util.c: assert(s); burn_strdup() -Abort on NULL string which would elsewise cuase a SIGSEGV +Abort on NULL string which would elsewise cause a SIGSEGV Used once in enumerate_common() with a string that worked with open(2) before : Severe Libburn Error => delete assert +ts A61008 + ------------------------------------------------------------------------------ - 48) libburn/util.c: assert(s); +++ 48) libburn/util.c: assert(s); burn_strndup(): - unused - Same as 47 @@ -631,9 +637,11 @@ Same as 47 => return NULL => delete assert +ts A61008 + ------------------------------------------------------------------------------ - 49) libburn/util.c: assert(n > 0); +++ 49) libburn/util.c: assert(n > 0); burn_strndup(): - unused - Prevent problems by negative copy length @@ -641,21 +649,24 @@ Prevent problems by negative copy length => return NULL => delete assert +ts A61008 + ------------------------------------------------------------------------------ - 50) libburn/write.c: assert(0); +++ 50) libburn/write.c: assert(0); static type_to_ctrl(): Unsuitable mode to be converted into "ctrl" Called by static type_to_form() finally burn_create_toc_entries() : Severe Application Error -=> to be caught at higher levels -=> issue LIBDAX_MSGS_SEV_WARNING -=> fall back to data mode +=> to be caught in burn_track_define_data by calling for test type_to_form() +=> return -1; + +ts A61008 ------------------------------------------------------------------------------ - 51) libburn/write.c: assert(0); +++ 51) libburn/write.c: assert(0); libburn/write.c: assert(0); /* XXX someone's gonna want this sometime */ static type_to_form(): Does not like BURN_MODE0 or BURN_MODE2 but tolerates unknown modes @@ -663,23 +674,33 @@ Does not like BURN_MODE0 or BURN_MODE2 but tolerates unknown modes Called by static burn_create_toc_entries() by burn_disc_write_sync() : Undocumented Libburn Restriction -=> Disallow BURN_MODE0 and BURN_MODE2 with API burn_track_define_data() -=> issue LIBDAX_MSGS_SEV_WARNING -=> default to BURN_MODE1 +=> set *form = -1 , *ctladr = 0xff , return +=> make function non-static +=> call for test in API burn_track_define_data() + +ts A61009 ------------------------------------------------------------------------------ - 52) libburn/write.c: assert(ptr); +++ 52) libburn/write.c: assert(ptr); static add_cue(): realloc() failed +Called by burn_create_toc_entries() by burn_disc_write_sync() +(burn_create_toc_entries is ignorant towards own potential memory problems) +(This could possibly really stay an abort() because the reason is + a plain failure of the system's memory management.) + : Severe System Error -=> This could possibly really stay an abort() because the reason is - a plain failure of the system's memory management. +=> change return type of add_cue to int +=> react on return -1 in burn_create_toc_entries, return NULL on failure +=> abort burn_disc_write_sync() on NULL return + +ts A61009 ------------------------------------------------------------------------------ - 53) libburn/write.c: assert(d->toc_entry == NULL); +++ 53) libburn/write.c: assert(d->toc_entry == NULL); burn_create_toc_entries(): Multiple usage of struct burn_drive.toc_entry @@ -688,19 +709,23 @@ This will probably trigger an abort with disc->sessions > 1 (disc->sessions is incremented in macro RESIZE() as "NEW##s") : Design Problem -=> ? disallow multiple sessions ? -=> ? leave assert in and wait what happens ? +( => ? disallow multiple sessions ? ) +=> replace assert by soft means and wait what happens + +ts A61009 ------------------------------------------------------------------------------ - 54) libburn/write.c: assert(0); +++ 54) libburn/write.c: assert(0); burn_sector_length(): Only BURN_AUDIO, BURN_MODE_RAW, BURN_MODE1 are allowed Called by get_sector(), convert_data(), ... -=> Only allow BURN_AUDIO, BURN_MODE_RAW, BURN_MODE1 with API burn_track_define_data() -=> delete assert +=> call burn_sector_length() for test in API burn_track_define_data() +=> replace assert by -1 + +ts A61009 ------------------------------------------------------------------------------ diff --git a/libburn/libdax_msgs.h b/libburn/libdax_msgs.h index 849468e..df8e4bd 100644 --- a/libburn/libdax_msgs.h +++ b/libburn/libdax_msgs.h @@ -320,6 +320,9 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff 0x00020112 (SORRY,HIGH) = Bad combination of write_type and block_type 0x00020113 (FATAL,HIGH) = Drive capabilities not inquired yet 0x00020114 (SORRY,HIGH) = Attempt to set ISRC with bad data + 0x00020115 (SORRY,HIGH) = Attempt to set track mode to unusable value + 0x00020116 (FATAL,HIGH) = Track mode has unusable value + 0x00020117 (FATAL,HIGH) = toc_entry of drive is already in use ------------------------------------------------------------------------------ diff --git a/libburn/structure.c b/libburn/structure.c index 161ca53..7d65f92 100644 --- a/libburn/structure.c +++ b/libburn/structure.c @@ -206,6 +206,23 @@ void burn_structure_print_track(struct burn_track *t) void burn_track_define_data(struct burn_track *t, int offset, int tail, int pad, int mode) { + int type_to_form(int mode, unsigned char *ctladr, int *form); + int burn_sector_length(int tracktype); + unsigned char ctladr; + int form = -1; /* unchanged form will be considered an error too */ + + type_to_form(mode, &ctladr, &form); + if (form == -1 || burn_sector_length(mode) <= 0) { + char msg[160]; + + sprintf(msg, "Attempt to set track mode to unusable value %d", + mode); + libdax_msgs_submit(libdax_messenger, -1, 0x00020115, + LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, + msg, 0, 0); + return; + } + t->offset = offset; t->pad = pad; t->mode = mode; diff --git a/libburn/write.c b/libburn/write.c index 5d0f2fd..56d46c9 100644 --- a/libburn/write.c +++ b/libburn/write.c @@ -2,7 +2,11 @@ #include #include -#include + +/* ts A61009 */ +/* #include */ + + #include #include #include @@ -22,6 +26,10 @@ #include "write.h" #include "options.h" +#include "libdax_msgs.h" +extern struct libdax_msgs *libdax_messenger; + + static int type_to_ctrl(int mode) { int ctrl = 0; @@ -36,7 +44,9 @@ static int type_to_ctrl(int mode) if (mode & BURN_PREEMPHASIS) ctrl |= 1; } else - assert(0); + /* ts A61008 */ + /* a ssert(0); */ + return -1; if (mode & BURN_COPY) ctrl |= 2; @@ -45,18 +55,40 @@ static int type_to_ctrl(int mode) } /* only the ctrl nibble is set here (not adr) */ -static void type_to_form(int mode, unsigned char *ctladr, int *form) +/* ts A61009 : removed "static" , reacted on type_to_ctrl() == -1 + preserved ignorance towards unknown modes (for now) */ +void type_to_form(int mode, unsigned char *ctladr, int *form) { - *ctladr = type_to_ctrl(mode) << 4; + int ret; + + ret = type_to_ctrl(mode) << 4; + if (ret == -1) { + *ctladr = 0xff; + *form = -1; + return; + } + *ctladr = ret; if (mode & BURN_AUDIO) *form = 0; - if (mode & BURN_MODE0) - assert(0); + if (mode & BURN_MODE0) { + + /* ts A61009 */ + /* a ssert(0); */ + *form = -1; + return; + } + if (mode & BURN_MODE1) *form = 0x10; - if (mode & BURN_MODE2) - assert(0); /* XXX someone's gonna want this sometime */ + if (mode & BURN_MODE2) { + + /* ts A61009 */ + /* a ssert(0); */ /* XXX someone's gonna want this sometime */ + *form = -1; + return; + } + if (mode & BURN_MODE_RAW) *form = 0; if (mode & BURN_SUBCODE_P16) /* must be expanded to R96 */ @@ -109,7 +141,9 @@ static void print_cue(struct cue_sheet *sheet) #endif /* Libburn_write_with_print_cuE */ -static void add_cue(struct cue_sheet *sheet, unsigned char ctladr, +/* ts A61009 : changed type from void to int */ +/** @return 1 = success , <=0 failure */ +static int add_cue(struct cue_sheet *sheet, unsigned char ctladr, unsigned char tno, unsigned char indx, unsigned char form, unsigned char scms, int lba) { @@ -121,7 +155,17 @@ static void add_cue(struct cue_sheet *sheet, unsigned char ctladr, sheet->count++; ptr = realloc(sheet->data, sheet->count * 8); - assert(ptr); + + /* ts A61009 */ + /* a ssert(ptr); */ + if (ptr == NULL) { + libdax_msgs_submit(libdax_messenger, -1, 0x00020111, + LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, + "Could not allocate new auxiliary object (cue_sheet->data)", + 0, 0); + return -1; + } + sheet->data = ptr; unit = sheet->data + (sheet->count - 1) * 8; unit[0] = ctladr; @@ -132,12 +176,13 @@ static void add_cue(struct cue_sheet *sheet, unsigned char ctladr, unit[5] = m; unit[6] = s; unit[7] = f; + return 1; } struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, struct burn_session *session) { - int i, m, s, f, form, pform, runtime = -150; + int i, m, s, f, form, pform, runtime = -150, ret; unsigned char ctladr; struct burn_drive *d; struct burn_toc_entry *e; @@ -149,17 +194,47 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, d = o->drive; sheet = malloc(sizeof(struct cue_sheet)); + + /* ts A61009 : react on failures of malloc(), add_cue_sheet() + type_to_form() */ + if (sheet == NULL) { + libdax_msgs_submit(libdax_messenger, -1, 0x00020111, + LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, + "Could not allocate new auxiliary object (cue_sheet)", + 0, 0); + return NULL; + } + sheet->data = NULL; sheet->count = 0; - type_to_form(tar[0]->mode, &ctladr, &form); - add_cue(sheet, ctladr | 1, 0, 0, 1, 0, runtime); - add_cue(sheet, ctladr | 1, 1, 0, form, 0, runtime); + if (form == -1) { + libdax_msgs_submit(libdax_messenger, -1, 0x00020116, + LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, + "Track mode has unusable value", 0, 0); + goto failed; + } + ret = add_cue(sheet, ctladr | 1, 0, 0, 1, 0, runtime); + if (ret <= 0) + goto failed; + ret = add_cue(sheet, ctladr | 1, 1, 0, form, 0, runtime); + if (ret <= 0) + goto failed; runtime += 150; burn_print(1, "toc for %d tracks:\n", ntr); d->toc_entries = ntr + 3; - assert(d->toc_entry == NULL); + + /* ts A61009 */ + /* a ssert(d->toc_entry == NULL); */ + if (d->toc_entry != NULL) { + libdax_msgs_submit(libdax_messenger, + d->global_index, 0x00020117, + LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, + "toc_entry of drive is already in use", 0, 0); + goto failed; + } + d->toc_entry = malloc(d->toc_entries * sizeof(struct burn_toc_entry)); e = d->toc_entry; memset((void *)e, 0, d->toc_entries * sizeof(struct burn_toc_entry)); @@ -187,7 +262,12 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, for (i = 0; i < ntr; i++) { type_to_form(tar[i]->mode, &ctladr, &form); if (pform != form) { - add_cue(sheet, ctladr | 1, i + 1, 0, form, 0, runtime); + + ret = add_cue(sheet, ctladr | 1, i + 1, 0, form, 0, + runtime); + if (ret <= 0) + goto failed; + runtime += 150; /* XXX fix pregap interval 1 for data tracks */ /* ts A60813 silence righteous compiler warning about C++ style comments @@ -210,7 +290,11 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, e[3 + i].control = type_to_ctrl(tar[i]->mode); burn_print(1, "track %d control %d\n", tar[i]->mode, e[3 + i].control); - add_cue(sheet, ctladr | 1, i + 1, 1, form, 0, runtime); + + ret = add_cue(sheet, ctladr | 1, i + 1, 1, form, 0, runtime); + if (ret <= 0) + goto failed; + runtime += burn_track_get_sectors(tar[i]); /* if we're padding, we'll clear any current shortage. if we're not, we'll slip toc entries by a sector every time our @@ -240,8 +324,15 @@ XXX this is untested :) burn_print(1, "point %d (%02d:%02d:%02d)\n", d->toc_entry[i].point, d->toc_entry[i].pmin, d->toc_entry[i].psec, d->toc_entry[i].pframe); - add_cue(sheet, ctladr | 1, 0xAA, 1, 1, 0, runtime); + ret = add_cue(sheet, ctladr | 1, 0xAA, 1, 1, 0, runtime); + if (ret <= 0) + goto failed; return sheet; + +failed:; + if (sheet != NULL) + free((char *) sheet); + return NULL; } int burn_sector_length(int tracktype) @@ -252,8 +343,9 @@ int burn_sector_length(int tracktype) return 2352; if (tracktype & BURN_MODE1) return 2048; - assert(0); - return 12345; + /* ts A61009 */ + /* a ssert(0); */ + return -1; } int burn_subcode_length(int tracktype) @@ -493,6 +585,11 @@ return crap. so we send the command, then ignore the result. d->progress.tracks = disc->session[i]->tracks; sheet = burn_create_toc_entries(o, disc->session[i]); + + /* ts A61009 */ + if (sheet == NULL) + goto fail; + /* print_cue(sheet);*/ if (o->write_type == BURN_WRITE_SAO) d->send_cue_sheet(d, sheet);