From e4efa066e19a68bb4e4d5312c679d85ce8c7e0b9 Mon Sep 17 00:00:00 2001 From: Don Lewis Date: Fri, 13 May 2016 05:49:02 +0000 Subject: [PATCH] Instead of ignoring the EEXIST from link(), unconditionally unlink the terget before calling link(). This should prevent links to an old copy of the file from being retained. --- usr.bin/catman/catman.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c index 90907a02fbd..47906f5c35f 100644 --- a/usr.bin/catman/catman.c +++ b/usr.bin/catman/catman.c @@ -422,9 +422,11 @@ process_page(char *mandir, char *src, char *cat, enum Ziptype zipped) fprintf(stderr, "%slink %s -> %s\n", verbose ? "\t" : "", cat, link_name); } - if (!pretend) - if (link(link_name, cat) < 0 && errno != EEXIST) + if (!pretend) { + (void) unlink(cat); + if (link(link_name, cat) < 0) warn("%s %s: link", link_name, cat); + } return; } insert_hashtable(links, src_ino, src_dev, strdup(cat));