From 5e52ac9aa4b738be9b68b1a2035dcf31aac8ebb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Buchm=C3=BCller?= Date: Sun, 26 May 2019 13:28:30 +0200 Subject: [PATCH] hfsprogs: add patches for (potential) issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Buchmüller --- srcpkgs/hfsprogs/patches/fix-binary-and.patch | 15 +++ .../fix-potential-buffer-overflow.patch | 37 ++++++ .../patches/use-inttypes_h-formats.patch | 112 ++++++++++++++++++ srcpkgs/hfsprogs/template | 2 +- 4 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/hfsprogs/patches/fix-binary-and.patch create mode 100644 srcpkgs/hfsprogs/patches/fix-potential-buffer-overflow.patch create mode 100644 srcpkgs/hfsprogs/patches/use-inttypes_h-formats.patch diff --git a/srcpkgs/hfsprogs/patches/fix-binary-and.patch b/srcpkgs/hfsprogs/patches/fix-binary-and.patch new file mode 100644 index 00000000000..0f0559d2344 --- /dev/null +++ b/srcpkgs/hfsprogs/patches/fix-binary-and.patch @@ -0,0 +1,15 @@ +Source: pullmoll +Upstream: no (should be reported) +Reason: needs binary and (&) to test for bit mask + +--- fsck_hfs.tproj/dfalib/SBTree.c 2012-02-01 18:17:19.000000000 +0100 ++++ fsck_hfs.tproj/dfalib/SBTree.c 2019-05-26 12:45:16.688514031 +0200 +@@ -502,7 +502,7 @@ + { + if ( recordSize != sizeof(HFSPlusCatalogFolder) ) + return false; +- if ( (catalogRecord->hfsPlusFolder.flags && (kHFSFileLockedMask | kHFSThreadExistsMask)) != 0 ) ++ if ( (catalogRecord->hfsPlusFolder.flags & (kHFSFileLockedMask | kHFSThreadExistsMask)) != 0 ) + return false; + + cNodeID = catalogRecord->hfsPlusFolder.folderID; diff --git a/srcpkgs/hfsprogs/patches/fix-potential-buffer-overflow.patch b/srcpkgs/hfsprogs/patches/fix-potential-buffer-overflow.patch new file mode 100644 index 00000000000..b656abde700 --- /dev/null +++ b/srcpkgs/hfsprogs/patches/fix-potential-buffer-overflow.patch @@ -0,0 +1,37 @@ +Source: pullmoll +Upstream: no (feel free to suggest) +Reason: use snprintf to avoid potential buffer overruns and fix mis-typed != compare + +--- fsck_hfs.tproj/utilities.c ++++ fsck_hfs.tproj/utilities.c +@@ -221,14 +221,12 @@ + if ((dp = strrchr(name, '/')) == 0) + return (0); + *dp = 0; +- (void)strncpy(rawbuf, name, sizeof(rawbuf)); +- *dp = '/'; + #if LINUX +- (void)strncat(rawbuf, "/", sizeof(rawbuf)); ++ snprintf(rawbuf, sizeof(rawbuf), "%s/%s", name, dp + 1); + #else +- (void)strncat(rawbuf, "/r", sizeof(rawbuf)); ++ snprintf(rawbuf, sizeof(rawbuf), "%s/r%s", name, dp + 1); + #endif +- (void)strncat(rawbuf, &dp[1], sizeof(rawbuf)); ++ *dp = '/'; + + return (rawbuf); + } +--- fsck_hfs.tproj/dfalib/SControl.c ++++ fsck_hfs.tproj/dfalib/SControl.c +@@ -321,9 +321,7 @@ + dataArea.DrvNum = fsReadRef; + dataArea.liveVerifyState = liveMode; + dataArea.scanCount = scanCount; +- if (strncpy(dataArea.deviceNode, rdevnode, sizeof(dataArea.deviceNode)) != strlen(rdevnode)) { +- dataArea.deviceNode[0] = '\0'; +- } ++ snprintf(dataArea.deviceNode, sizeof(dataArea.deviceNode), "%s", rdevnode); + + /* there are cases where we cannot get the name of the volume so we */ + /* set our default name to one blank */ diff --git a/srcpkgs/hfsprogs/patches/use-inttypes_h-formats.patch b/srcpkgs/hfsprogs/patches/use-inttypes_h-formats.patch new file mode 100644 index 00000000000..35bf820eb8c --- /dev/null +++ b/srcpkgs/hfsprogs/patches/use-inttypes_h-formats.patch @@ -0,0 +1,112 @@ +Source: pullmoll +Upstream: no +Reason: avoid format string mismatch for 64 bit types on 32/64 bit arch + +--- newfs_hfs.tproj/newfs_hfs.c ++++ newfs_hfs.tproj/newfs_hfs.c +@@ -34,6 +34,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -203,7 +203,7 @@ + if (isdigit(optarg[0])) { + gJournalSize = get_num(optarg); + if (gJournalSize < 512*1024) { +- printf("%s: journal size %lldk too small. Reset to %dk.\n", ++ printf("%s: journal size %" PRId64 "k too small. Reset to %dk.\n", + progname, gJournalSize/1024, JOURNAL_DEFAULT_SIZE/1024); + gJournalSize = JOURNAL_DEFAULT_SIZE; + } +@@ -636,7 +636,7 @@ + } + + if (bit_index >= 22) { +- fatal("Error: Disk Device is too big (%llu sectors, %d bytes per sector", sectorCount, sectorSize); ++ fatal("Error: Disk Device is too big (%" PRIu64 " sectors, %d bytes per sector", sectorCount, sectorSize); + } + } + else { +@@ -646,7 +646,7 @@ + } + + if ((sectorCount / (gBlockSize / sectorSize)) > 0xFFFFFFFF) { +- fatal("%s: block size is too small for %lld sectors", optarg, gBlockSize, sectorCount); ++ fatal("%s: block size is too small for %" PRId64 " sectors", optarg, gBlockSize, sectorCount); + } + + if (gBlockSize < HFSOPTIMALBLKSIZE) { +@@ -769,7 +769,7 @@ + /* Check to see if the disk is too big */ + u_int64_t secsize = (u_int64_t) dip.sectorSize; + if (bad_disk_size(dip.totalSectors, secsize)) { +- fatal("%s: partition is too big (maximum is %llu KB)", device, MAXHFSVOLSIZE/1024); ++ fatal("%s: partition is too big (maximum is %" PRIu64 " KB)", device, MAXHFSVOLSIZE/1024); + } + + /* +@@ -904,7 +904,7 @@ + min_size = dip->physSectorSize * (dip->physSectorSize / BLOCK_INFO_SIZE); + + if (gJournalSize < min_size) { +- printf("%s: journal size %lldk too small. Reset to %dk.\n", ++ printf("%s: journal size %" PRId64 "k too small. Reset to %dk.\n", + progname, gJournalSize/1024, JOURNAL_DEFAULT_SIZE/1024); + gJournalSize = 0; + } +@@ -1055,7 +1055,7 @@ + + if (gNoCreate) { + if (gPartitionSize == 0) +- printf("%llu sectors (%u bytes per sector)\n", dip->physTotalSectors, dip->physSectorSize); ++ printf("%" PRIu64 " sectors (%u bytes per sector)\n", dip->physTotalSectors, dip->physSectorSize); + printf("HFS Plus format parameters:\n"); + printf("\tvolume name: \"%s\"\n", gVolumeName); + printf("\tblock-size: %u\n", defaults->blockSize); +--- newfs_hfs.tproj/makehfs.c ++++ newfs_hfs.tproj/makehfs.c +@@ -55,6 +55,7 @@ + #if !LINUX + #include + #endif ++#include + + /* + * CommonCrypto is meant to be a more stable API than OpenSSL. +@@ -1380,10 +1381,10 @@ + err(1, NULL); + } + else if (2 == status) { +- err(1, "read (sector %llu)", physSector); ++ err(1, "read (sector %" PRIu64 ")", physSector); + } + else if (3 == status) { +- err(1, "write (sector %llu)", physSector); ++ err(1, "write (sector %" PRIu64 ")", physSector); + } + + return; +--- fsck_hfs.tproj/dfalib/CatalogCheck.c 2012-02-01 18:17:19.000000000 +0100 ++++ fsck_hfs.tproj/dfalib/CatalogCheck.c 2019-05-26 13:03:31.395612279 +0200 +@@ -25,6 +25,7 @@ + #include "DecompDataEnums.h" + #include "DecompData.h" + ++#include + #include + + extern int RcdFCntErr( SGlobPtr GPtr, OSErr type, UInt32 correct, UInt32 incorrect, HFSCatalogNodeID); +@@ -1693,8 +1694,8 @@ + } else { + fsckPrint(gScavGlobals->context, E_LEOF, filename); + } +- sprintf(oldSizeStr, "%qd", oldSize); +- sprintf(newSizeStr, "%qd", newSize); ++ sprintf(oldSizeStr, "%" PRIu64, oldSize); ++ sprintf(newSizeStr, "%" PRIu64, newSize); + fsckPrint(gScavGlobals->context, E_BadValue, newSizeStr, oldSizeStr); + + /* Only HFS+ is repaired here */ diff --git a/srcpkgs/hfsprogs/template b/srcpkgs/hfsprogs/template index e70cd66bb54..daa18b686ae 100644 --- a/srcpkgs/hfsprogs/template +++ b/srcpkgs/hfsprogs/template @@ -3,7 +3,7 @@ pkgname=hfsprogs _distver=540.1 _patchver=3 version="${_distver}.linux${_patchver}" -revision=3 +revision=4 wrksrc="diskdev_cmds-${version}" hostmakedepends="clang" makedepends="libressl-devel libuuid-devel"