diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index be42733..eb0041a 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Mario Danic - * Copyright (c) 2009 - 2012 Thomas Schmitt + * Copyright (c) 2009 - 2013 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -1613,7 +1613,8 @@ int checksum_prepare_nodes(Ecma119Image *target, IsoNode *node, int flag) */; } else if (ret == 1 && img->checksum_array == NULL) { /* No checksum array loaded. Delete "isofs.cx" */ - iso_node_set_attrs(node, (size_t) 1, + if (!target->will_cancel) + iso_node_set_attrs(node, (size_t) 1, &cx_names, cx_value_lengths, &cx_valuept, 4 | 8); no_md5 = 1; } else if (ret == 1 && value_length == 4) { @@ -1639,8 +1640,9 @@ int checksum_prepare_nodes(Ecma119Image *target, IsoNode *node, int flag) } /* Equip nodes with provisory isofs.cx numbers: 4 byte, all 0. Omit those from old image which will not be copied and have no MD5. + Do not alter the nodes if this is only a will_cancel run. */ - if (!no_md5) { + if (!(target->will_cancel || no_md5)) { ret = iso_file_set_isofscx(file, (unsigned int) 0, 0); if (ret < 0) return ret; diff --git a/libisofs/filesrc.c b/libisofs/filesrc.c index c3feb8c..654054a 100644 --- a/libisofs/filesrc.c +++ b/libisofs/filesrc.c @@ -127,7 +127,7 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src) /* insert the filesrc in the tree */ ret = iso_rbtree_insert(img->files, fsrc, (void**)src); if (ret <= 0) { - if (ret == 0 && (*src)->checksum_index > 0) { + if (ret == 0 && (*src)->checksum_index > 0 && !img->will_cancel) { /* Duplicate file source was mapped to previously registered source */ cret = iso_file_set_isofscx(file, (*src)->checksum_index, 0); @@ -152,7 +152,7 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src) no_md5 = 1; } - if ((img->md5_file_checksums & 1) && !no_md5) { + if ((img->md5_file_checksums & 1) && !(no_md5 || img->will_cancel)) { img->checksum_idx_counter++; if (img->checksum_idx_counter < 0x7fffffff) { fsrc->checksum_index = img->checksum_idx_counter; diff --git a/libisofs/md5.c b/libisofs/md5.c index 7c192a7..cd75eb5 100644 --- a/libisofs/md5.c +++ b/libisofs/md5.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Thomas Schmitt + * Copyright (c) 2009 - 2013 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -527,18 +527,25 @@ int checksum_copy_old_nodes(Ecma119Image *target, IsoNode *node, int flag) if (md5_pt == NULL) return 0; - ret = iso_node_lookup_attr(node, "isofs.cx", &value_length, - &value, 0); - if (ret == 1 && value_length == 4) { - for (i = 0; i < 4; i++) - idx = (idx << 8) | ((unsigned char *) value)[i]; - if (idx > 0 && idx <= target->checksum_idx_counter) { - memcpy(target->checksum_buffer + 16 * idx, md5_pt, 16); + if (!target->will_cancel) { + ret = iso_node_lookup_attr(node, "isofs.cx", &value_length, + &value, 0); + if (ret == 1 && value_length == 4) { + for (i = 0; i < 4; i++) + idx = (idx << 8) | ((unsigned char *) value)[i]; + if (idx > 0 && idx <= target->checksum_idx_counter) { + memcpy(target->checksum_buffer + 16 * idx, md5_pt, 16); + } } + if (value != NULL) + free(value); + + /* ts B30114 : It is unclear why these are removed here. + At least with the opts->will_cancel runs, + this is not appropriate. + */ + iso_node_remove_xinfo(node, checksum_md5_xinfo_func); } - if (value != NULL) - free(value); - iso_node_remove_xinfo(node, checksum_md5_xinfo_func); iso_node_remove_xinfo(node, checksum_cx_xinfo_func); } } else if (node->type == LIBISO_DIR) {