From: наб Date: Mon, 28 Oct 2024 18:19:34 +0000 (+0100) Subject: hardlink: fix 0-sized file processing X-Git-Tag: v2.42-start~166 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91bd4db8260814298166604073a67ab8e1030a01;p=thirdparty%2Futil-linux.git hardlink: fix 0-sized file processing The manual says that -s0 will process 0-sized files normally, but as it stands (a) hardlink considers 0-sized files unlinkable (so, with -l, unlistable) and (b) fileeq considers reading an empty prologue to be an error --- diff --git a/lib/fileeq.c b/lib/fileeq.c index b40eba2b0..1f7f90ccb 100644 --- a/lib/fileeq.c +++ b/lib/fileeq.c @@ -465,7 +465,7 @@ static ssize_t get_intro(struct ul_fileeq *eq, struct ul_fileeq_data *data, return -1; rsz = read_all(fd, (char *) data->intro, sizeof(data->intro)); DBG(DATA, ul_debugobj(data, " read %zu bytes intro", sizeof(data->intro))); - if (rsz <= 0) + if (rsz < 0) return -1; data->nblocks = 1; } diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c index 643df7cf2..8c5f24aad 100644 --- a/misc-utils/hardlink.c +++ b/misc-utils/hardlink.c @@ -649,8 +649,7 @@ static int file_xattrs_equal(const struct file *a, const struct file *b) */ static int file_may_link_to(const struct file *a, const struct file *b) { - return (a->st.st_size != 0 && - a->st.st_size == b->st.st_size && + return (a->st.st_size == b->st.st_size && a->links != NULL && b->links != NULL && a->st.st_dev == b->st.st_dev && a->st.st_ino != b->st.st_ino &&