Skip to content

Commit

Permalink
Revert "Fix checksum failure with small isos"
Browse files Browse the repository at this point in the history
This reverts commit e313746.

This patch causes short checksums (57 characters instead of 60) to be
written, resulting in a checksum that doesn't cover the whole iso and
which fails when checked with previous checkisomd5sum versions.

The incorrect checksums are shown with a ';FR' at the end instead of the
last 3 digits.
  • Loading branch information
bcl committed Apr 29, 2024
1 parent 3f4c9bd commit 14e4bac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libcheckisomd5.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static enum isomd5sum_status checkmd5sum(int isofd, checkCallback cb, void *cbda
size_t previous_fragment = 0UL;
off_t offset = 0LL;
while (offset < total_size) {
const size_t nbyte = MIN((size_t)(total_size - offset), MIN(fragment_size, buffer_size));
const size_t nbyte = MIN((size_t)(total_size - offset), buffer_size);

ssize_t nread = read(isofd, buffer, nbyte);
if (nread <= 0L)
Expand All @@ -89,7 +89,7 @@ static enum isomd5sum_status checkmd5sum(int isofd, checkCallback cb, void *cbda
const size_t current_fragment = offset / fragment_size;
const size_t fragmentsize = FRAGMENT_SUM_SIZE / info->fragmentcount;
/* If we're onto the next fragment, calculate the previous sum and check. */
if (current_fragment != previous_fragment && current_fragment < info->fragmentcount) {
if (current_fragment != previous_fragment) {
if (!validate_fragment(&hashctx, current_fragment, fragmentsize,
info->fragmentsums, NULL)) {
/* Exit immediately if current fragment sum is incorrect */
Expand Down
6 changes: 3 additions & 3 deletions libimplantisomd5.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ int implantISOFD(int isofd, int supported, int forceit, int quiet, char **errstr
const off_t fragment_size = total_size / (FRAGMENT_COUNT + 1);
size_t previous_fragment = 0UL;
off_t offset = 0LL;
while (offset < total_size && previous_fragment < FRAGMENT_COUNT) {
const size_t nbyte = MIN((size_t)(total_size - offset), MIN(fragment_size, buffer_size));
while (offset < total_size) {
const size_t nbyte = MIN((size_t)(total_size - offset), buffer_size);
ssize_t nread = read(isofd, buffer, nbyte);
if (nread <= 0L)
break;
Expand All @@ -119,7 +119,7 @@ int implantISOFD(int isofd, int supported, int forceit, int quiet, char **errstr
const size_t current_fragment = offset / fragment_size;
const size_t fragmentsize = FRAGMENT_SUM_SIZE / FRAGMENT_COUNT;
/* If we're onto the next fragment, calculate the previous sum and check. */
if (current_fragment != previous_fragment && current_fragment < FRAGMENT_COUNT) {
if (current_fragment != previous_fragment) {
validate_fragment(&hashctx, current_fragment, fragmentsize, NULL, fragmentsums);
previous_fragment = current_fragment;
}
Expand Down

0 comments on commit 14e4bac

Please sign in to comment.