Skip to content

Commit

Permalink
Merge branch 'PR/hardlink-mem-issues' of https://github.com/karelzak/…
Browse files Browse the repository at this point in the history
…util-linux-work

* 'PR/hardlink-mem-issues' of https://github.com/karelzak/util-linux-work:
  hardlink: fix memory corruption (size calculation)
  • Loading branch information
karelzak committed Jan 3, 2025
2 parents 5a295e9 + 70c1ffb commit 33d4a41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fileeq.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ size_t ul_fileeq_set_size(struct ul_fileeq *eq, uint64_t filesiz,
nreads = filesiz / readsiz;
/* enlarge readsize for large files */
if (nreads > maxdigs)
readsiz = filesiz / maxdigs;
readsiz = (filesiz + maxdigs - 1) / maxdigs;
break;
}

eq->readsiz = readsiz;
eq->blocksmax = filesiz / readsiz;
eq->blocksmax = (filesiz + readsiz - 1) / readsiz;

DBG(EQ, ul_debugobj(eq, "set sizes: filesiz=%ju, maxblocks=%" PRIu64 ", readsiz=%zu",
eq->filesiz, eq->blocksmax, eq->readsiz));
Expand Down

0 comments on commit 33d4a41

Please sign in to comment.