Bug fix: Image size prediction altered the pointers to MD5 of data files

which stem from a previous session.
This commit is contained in:
Thomas Schmitt 2013-01-14 18:13:49 +01:00
parent 05e7f84966
commit 6905ab3e56
3 changed files with 25 additions and 16 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Vreixo Formoso
* Copyright (c) 2007 Mario Danic * 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 * 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 * 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) { } else if (ret == 1 && img->checksum_array == NULL) {
/* No checksum array loaded. Delete "isofs.cx" */ /* 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); &cx_names, cx_value_lengths, &cx_valuept, 4 | 8);
no_md5 = 1; no_md5 = 1;
} else if (ret == 1 && value_length == 4) { } 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. /* 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. 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); ret = iso_file_set_isofscx(file, (unsigned int) 0, 0);
if (ret < 0) if (ret < 0)
return ret; return ret;

View File

@ -127,7 +127,7 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
/* insert the filesrc in the tree */ /* insert the filesrc in the tree */
ret = iso_rbtree_insert(img->files, fsrc, (void**)src); ret = iso_rbtree_insert(img->files, fsrc, (void**)src);
if (ret <= 0) { 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 /* Duplicate file source was mapped to previously registered source
*/ */
cret = iso_file_set_isofscx(file, (*src)->checksum_index, 0); 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; 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++; img->checksum_idx_counter++;
if (img->checksum_idx_counter < 0x7fffffff) { if (img->checksum_idx_counter < 0x7fffffff) {
fsrc->checksum_index = img->checksum_idx_counter; fsrc->checksum_index = img->checksum_idx_counter;

View File

@ -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 * 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 * 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) if (md5_pt == NULL)
return 0; return 0;
ret = iso_node_lookup_attr(node, "isofs.cx", &value_length, if (!target->will_cancel) {
&value, 0); ret = iso_node_lookup_attr(node, "isofs.cx", &value_length,
if (ret == 1 && value_length == 4) { &value, 0);
for (i = 0; i < 4; i++) if (ret == 1 && value_length == 4) {
idx = (idx << 8) | ((unsigned char *) value)[i]; for (i = 0; i < 4; i++)
if (idx > 0 && idx <= target->checksum_idx_counter) { idx = (idx << 8) | ((unsigned char *) value)[i];
memcpy(target->checksum_buffer + 16 * idx, md5_pt, 16); 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); iso_node_remove_xinfo(node, checksum_cx_xinfo_func);
} }
} else if (node->type == LIBISO_DIR) { } else if (node->type == LIBISO_DIR) {