| @@ -1,23 +1,23 @@ | | | @@ -1,23 +1,23 @@ |
1 | /* $NetBSD: plist.c,v 1.30 2020/03/01 11:02:04 rillig Exp $ */ | | 1 | /* $NetBSD: plist.c,v 1.31 2020/09/07 23:46:42 wiz Exp $ */ |
2 | | | 2 | |
3 | #if HAVE_CONFIG_H | | 3 | #if HAVE_CONFIG_H |
4 | #include "config.h" | | 4 | #include "config.h" |
5 | #endif | | 5 | #endif |
6 | #include <nbcompat.h> | | 6 | #include <nbcompat.h> |
7 | #if HAVE_SYS_CDEFS_H | | 7 | #if HAVE_SYS_CDEFS_H |
8 | #include <sys/cdefs.h> | | 8 | #include <sys/cdefs.h> |
9 | #endif | | 9 | #endif |
10 | __RCSID("$NetBSD: plist.c,v 1.30 2020/03/01 11:02:04 rillig Exp $"); | | 10 | __RCSID("$NetBSD: plist.c,v 1.31 2020/09/07 23:46:42 wiz Exp $"); |
11 | | | 11 | |
12 | /* | | 12 | /* |
13 | * FreeBSD install - a package for the installation and maintainance | | 13 | * FreeBSD install - a package for the installation and maintainance |
14 | * of non-core utilities. | | 14 | * of non-core utilities. |
15 | * | | 15 | * |
16 | * Redistribution and use in source and binary forms, with or without | | 16 | * Redistribution and use in source and binary forms, with or without |
17 | * modification, are permitted provided that the following conditions | | 17 | * modification, are permitted provided that the following conditions |
18 | * are met: | | 18 | * are met: |
19 | * 1. Redistributions of source code must retain the above copyright | | 19 | * 1. Redistributions of source code must retain the above copyright |
20 | * notice, this list of conditions and the following disclaimer. | | 20 | * notice, this list of conditions and the following disclaimer. |
21 | * 2. Redistributions in binary form must reproduce the above copyright | | 21 | * 2. Redistributions in binary form must reproduce the above copyright |
22 | * notice, this list of conditions and the following disclaimer in the | | 22 | * notice, this list of conditions and the following disclaimer in the |
23 | * documentation and/or other materials provided with the distribution. | | 23 | * documentation and/or other materials provided with the distribution. |
| @@ -617,35 +617,38 @@ delete_package(Boolean ign_err, package_ | | | @@ -617,35 +617,38 @@ delete_package(Boolean ign_err, package_ |
617 | } else if (strncmp(p->next->name, SYMLINK_HEADER, SymlinkHeaderLen) == 0) { | | 617 | } else if (strncmp(p->next->name, SYMLINK_HEADER, SymlinkHeaderLen) == 0) { |
618 | char buf[MaxPathSize + SymlinkHeaderLen]; | | 618 | char buf[MaxPathSize + SymlinkHeaderLen]; |
619 | int cc; | | 619 | int cc; |
620 | | | 620 | |
621 | (void) strlcpy(buf, SYMLINK_HEADER, | | 621 | (void) strlcpy(buf, SYMLINK_HEADER, |
622 | sizeof(buf)); | | 622 | sizeof(buf)); |
623 | if ((cc = readlink(tmp, &buf[SymlinkHeaderLen], | | 623 | if ((cc = readlink(tmp, &buf[SymlinkHeaderLen], |
624 | sizeof(buf) - SymlinkHeaderLen - 1)) < 0) { | | 624 | sizeof(buf) - SymlinkHeaderLen - 1)) < 0) { |
625 | warn("can't readlink `%s'", tmp); | | 625 | warn("can't readlink `%s'", tmp); |
626 | goto pkgdb_cleanup; | | 626 | goto pkgdb_cleanup; |
627 | } | | 627 | } |
628 | buf[SymlinkHeaderLen + cc] = 0x0; | | 628 | buf[SymlinkHeaderLen + cc] = 0x0; |
629 | if (strcmp(buf, p->next->name) != 0) { | | 629 | if (strcmp(buf, p->next->name) != 0) { |
630 | if ((cc = readlink(&buf[SymlinkHeaderLen], &buf[SymlinkHeaderLen], | | 630 | char tmp2[MaxPathSize]; |
631 | sizeof(buf) - SymlinkHeaderLen)) < 0) { | | 631 | |
| | | 632 | if ((cc = readlink(&buf[SymlinkHeaderLen], tmp2, |
| | | 633 | sizeof(tmp2))) < 0) { |
632 | printf("symlink %s is not same as recorded value, %s: %s\n", | | 634 | printf("symlink %s is not same as recorded value, %s: %s\n", |
633 | buf, Force ? "deleting anyway" : "not deleting", tmp); | | 635 | buf, Force ? "deleting anyway" : "not deleting", tmp); |
634 | if (!Force) { | | 636 | if (!Force) { |
635 | fail = FAIL; | | 637 | fail = FAIL; |
636 | goto pkgdb_cleanup; | | 638 | goto pkgdb_cleanup; |
637 | } | | 639 | } |
638 | } | | 640 | } |
| | | 641 | memcpy(&buf[SymlinkHeaderLen], tmp2, cc); |
639 | buf[SymlinkHeaderLen + cc] = 0x0; | | 642 | buf[SymlinkHeaderLen + cc] = 0x0; |
640 | if (strcmp(buf, p->next->name) != 0) { | | 643 | if (strcmp(buf, p->next->name) != 0) { |
641 | printf("symlink %s is not same as recorded value, %s: %s\n", | | 644 | printf("symlink %s is not same as recorded value, %s: %s\n", |
642 | buf, Force ? "deleting anyway" : "not deleting", tmp); | | 645 | buf, Force ? "deleting anyway" : "not deleting", tmp); |
643 | if (!Force) { | | 646 | if (!Force) { |
644 | fail = FAIL; | | 647 | fail = FAIL; |
645 | goto pkgdb_cleanup; | | 648 | goto pkgdb_cleanup; |
646 | } | | 649 | } |
647 | } | | 650 | } |
648 | } | | 651 | } |
649 | } | | 652 | } |
650 | } | | 653 | } |
651 | if (Verbose && !NoDeleteFiles) | | 654 | if (Verbose && !NoDeleteFiles) |