]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
- don't try to hardlink 0 byte files (#154404)
authorJeremy Katz <katzj@fedoraproject.org>
Wed, 27 Apr 2005 22:05:13 +0000 (22:05 +0000)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 12 Jun 2018 12:22:59 +0000 (14:22 +0200)
misc-utils/hardlink.c

index 52cb41f42204c69d29714f18a1e6b75422b4e45b..7a6cf6f520c7e4944c05cbf65d5210524b4c7d91 100644 (file)
@@ -175,7 +175,7 @@ void rf (char *name)
           fprintf(stderr, "\r%*s\r", (int)strlen(name)+2, "");
         return;
       }
-    if (fp) {
+    if (fp && st.st_size > 0) {
       p = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
       nmmap++;
       if (p == (void *)-1) {
@@ -191,7 +191,7 @@ void rf (char *name)
           st2.st_dev == st.st_dev) {
         int fd2 = open (fp2->name, O_RDONLY);
         if (fd2 < 0) continue;
-        if (fstat (fd2, &st2) || !S_ISREG (st2.st_mode)) {
+        if (fstat (fd2, &st2) || !S_ISREG (st2.st_mode) || st2.st_size == 0) {
           close (fd2);
           continue;
         }