From 6ebbd03423675e4a8e37b44e216b9edeb2015535 Mon Sep 17 00:00:00 2001
From: JJTech0130 <53275876+JJTech0130@users.noreply.github.com>
Date: Wed, 23 Mar 2022 16:50:31 -0400
Subject: [PATCH 1/9] Remove ldid2
---
ldid2/.gitignore | 7 -
ldid2/.gitmodules | 3 -
ldid2/COPYING | 661 -
ldid2/control | 11 -
ldid2/control.sh | 5 -
ldid2/deb.sh | 10 -
ldid2/ios.sh | 2 -
ldid2/ldid.cpp | 2788 -
ldid2/ldid.hpp | 159 -
ldid2/libplist/.gitignore | 56 -
ldid2/libplist/AUTHORS | 28 -
ldid2/libplist/COPYING | 340 -
ldid2/libplist/COPYING.LESSER | 502 -
ldid2/libplist/Makefile.am | 18 -
ldid2/libplist/NEWS | 209 -
ldid2/libplist/README.md | 55 -
ldid2/libplist/autogen.sh | 22 -
ldid2/libplist/configure.ac | 289 -
ldid2/libplist/cython/Makefile.am | 30 -
ldid2/libplist/cython/plist.pxd | 73 -
ldid2/libplist/cython/plist.pyx | 854 -
ldid2/libplist/cython/plist_util.c | 40 -
ldid2/libplist/cython/plist_util.h | 5 -
ldid2/libplist/doxygen.cfg.in | 1417 -
ldid2/libplist/fuzz/Makefile.am | 36 -
.../clusterfuzz-testcase-4766291097288704 | Bin 79 -> 0 bytes
.../clusterfuzz-testcase-4930725262393344 | Bin 123 -> 0 bytes
.../clusterfuzz-testcase-5421965105954816 | Bin 77 -> 0 bytes
.../clusterfuzz-testcase-5556177727389696 | Bin 140 -> 0 bytes
.../clusterfuzz-testcase-6557963011489792 | Bin 1376 -> 0 bytes
.../clusterfuzz-testcase-6605859144597504 | Bin 194 -> 0 bytes
...h-0ce4dd483b645bc05ec45a97d285dcf1933ee840 | Bin 77 -> 0 bytes
...h-0d59cdcb5c3416c2790612b78a631ce9f5622800 | Bin 156 -> 0 bytes
...h-17d635ab460fef74df1ac7561f1253533a6359c5 | Bin 52 -> 0 bytes
...h-33a67313fa7864cd627ef92d12017a127d342f28 | Bin 77 -> 0 bytes
...h-39f1347115f8fe9ac25cdc9332e3fc5cd32c7f7b | Bin 50 -> 0 bytes
...h-4bd78175fe01d07c5ee90104fbc68d95dd092210 | Bin 120 -> 0 bytes
...h-4c5404453bb7425aef9b953a5f6f3f0afcc48392 | Bin 77 -> 0 bytes
...h-52775e25f6af20af351cd616834e602fc988a032 | Bin 103 -> 0 bytes
...h-6d1399685b745d3d49fadc91072fabcdde8d16fa | Bin 62 -> 0 bytes
...h-94b3725900d63c6258448fd757559c81002de9c9 | Bin 38 -> 0 bytes
...h-a47195acbabc3f5b2cda9c6ebda42f2afc1cc5af | Bin 77 -> 0 bytes
...h-ce852bae6aeeffc4698a93660236f1b995ce966e | Bin 54 -> 0 bytes
...h-daddb6e82e3d1ed76e20e4131462f5247a6fb131 | Bin 54 -> 0 bytes
...h-f21be4ebce7f9c337bf96b93cec7e252f5c75a21 | Bin 102 -> 0 bytes
...h-f779dafccc0164684d1a264976e56037188b40e2 | Bin 391 -> 0 bytes
...k-96fb453b3ba18d31e164831795a708183b5a0dac | Bin 1156 -> 0 bytes
...k-acb3c00a83d7635638a476a4e70fc1f1caa1a5b1 | Bin 1085 -> 0 bytes
...k-fe2cd4b1f67e0c9b21e6225a4fb4ca19eab80074 | Bin 1915 -> 0 bytes
ldid2/libplist/fuzz/bplist.dict | 1 -
ldid2/libplist/fuzz/bplist_fuzzer.cc | 32 -
ldid2/libplist/fuzz/bplist_fuzzer.options | 3 -
ldid2/libplist/fuzz/fuzzers.test | 8 -
ldid2/libplist/fuzz/init-fuzzers.sh | 23 -
ldid2/libplist/fuzz/test-fuzzers.sh | 33 -
.../clusterfuzz-testcase-4516959125241856 | Bin 408 -> 0 bytes
.../clusterfuzz-testcase-4663876528373760 | 5 -
.../clusterfuzz-testcase-5799076113154048 | 45 -
.../clusterfuzz-testcase-5922404220010496 | Bin 1132 -> 0 bytes
.../clusterfuzz-testcase-6015098361479168 | Bin 1567 -> 0 bytes
.../clusterfuzz-testcase-6043836860071936 | Bin 3845 -> 0 bytes
.../clusterfuzz-testcase-6047509906456576 | 10050 ---
.../clusterfuzz-testcase-6482601374121984 | Bin 613 -> 0 bytes
...h-09788d7acb46b4b177422f9c4ee54556a3ad1f17 | 53 -
...h-155c60d5c4b2778110fb4a633caa7d64eb9b99c1 | 9 -
...h-348c909a0b3532977185f551eb5d2ed04e694883 | 11 -
...h-7bc172e27a2b1d4fcaf031f59d1f08fb83081e4a | 8 -
...h-80c28b0e2a446665e68927dd4441c10c9a68e64e | Bin 1730 -> 0 bytes
...h-8acf177da60ecf13c36d0da1b8e25de891980ea6 | 5 -
...h-94276cf69a50e78dd6cdf079c208cb80f357cd33 | Bin 1013 -> 0 bytes
...h-9ddb891a0ec42401eb4629e6b99e01aef7909eb9 | Bin 4096 -> 0 bytes
...h-a8b44e1f5be4f75f00a937016ec5405bce77a0f9 | Bin 2342 -> 0 bytes
...h-da39a3ee5e6b4b0d3255bfef95601890afd80709 | 0
...h-f03c680ee1c4d84c28e731752df77a61e213a24d | 72 -
.../clusterfuzz-testcase-4634751103139840 | 187 -
.../clusterfuzz-testcase-6056412121661440 | 12 -
...k-47b0a9f21d3affab6cfc898e5140bb53265ada07 | Bin 4096 -> 0 bytes
...k-4c81aae70b20d9b9408b78d40999a54205bdcfb7 | Bin 557 -> 0 bytes
...k-53bc466851eda790bd891733da5db0a7482886bf | 6 -
ldid2/libplist/fuzz/xplist.dict | 51 -
ldid2/libplist/fuzz/xplist_fuzzer.cc | 32 -
ldid2/libplist/fuzz/xplist_fuzzer.options | 3 -
ldid2/libplist/include/Makefile.am | 14 -
ldid2/libplist/include/plist/Array.h | 55 -
ldid2/libplist/include/plist/Boolean.h | 48 -
ldid2/libplist/include/plist/Data.h | 49 -
ldid2/libplist/include/plist/Date.h | 50 -
ldid2/libplist/include/plist/Dictionary.h | 64 -
ldid2/libplist/include/plist/Integer.h | 48 -
ldid2/libplist/include/plist/Key.h | 49 -
ldid2/libplist/include/plist/Node.h | 57 -
ldid2/libplist/include/plist/Real.h | 48 -
ldid2/libplist/include/plist/String.h | 49 -
ldid2/libplist/include/plist/Structure.h | 59 -
ldid2/libplist/include/plist/Uid.h | 48 -
ldid2/libplist/include/plist/plist++.h | 39 -
ldid2/libplist/include/plist/plist.h | 730 -
ldid2/libplist/libcnary/COPYING | 502 -
ldid2/libplist/libcnary/Makefile.am | 12 -
ldid2/libplist/libcnary/README | 5 -
ldid2/libplist/libcnary/cnary.c | 46 -
ldid2/libplist/libcnary/include/node.h | 73 -
ldid2/libplist/libcnary/include/node_list.h | 55 -
ldid2/libplist/libcnary/include/object.h | 41 -
ldid2/libplist/libcnary/node.c | 216 -
ldid2/libplist/libcnary/node_list.c | 155 -
ldid2/libplist/m4/ac_pkg_cython.m4 | 67 -
ldid2/libplist/m4/as-compiler-flag.m4 | 62 -
ldid2/libplist/m4/ax_pthread.m4 | 485 -
ldid2/libplist/m4/ax_python_devel.m4 | 327 -
ldid2/libplist/m4/cython_python.m4 | 7 -
ldid2/libplist/src/Array.cpp | 148 -
ldid2/libplist/src/Boolean.cpp | 73 -
ldid2/libplist/src/Data.cpp | 79 -
ldid2/libplist/src/Date.cpp | 76 -
ldid2/libplist/src/Dictionary.cpp | 167 -
ldid2/libplist/src/Integer.cpp | 73 -
ldid2/libplist/src/Key.cpp | 80 -
ldid2/libplist/src/Makefile.am | 52 -
ldid2/libplist/src/Node.cpp | 166 -
ldid2/libplist/src/Real.cpp | 73 -
ldid2/libplist/src/String.cpp | 80 -
ldid2/libplist/src/Structure.cpp | 123 -
ldid2/libplist/src/Uid.cpp | 73 -
ldid2/libplist/src/base64.c | 119 -
ldid2/libplist/src/base64.h | 28 -
ldid2/libplist/src/bplist.c | 1381 -
ldid2/libplist/src/bytearray.c | 61 -
ldid2/libplist/src/bytearray.h | 36 -
ldid2/libplist/src/hashtable.c | 140 -
ldid2/libplist/src/hashtable.h | 50 -
ldid2/libplist/src/libplist++.pc.in | 11 -
ldid2/libplist/src/libplist.pc.in | 10 -
ldid2/libplist/src/plist.c | 1113 -
ldid2/libplist/src/plist.h | 74 -
ldid2/libplist/src/ptrarray.c | 91 -
ldid2/libplist/src/ptrarray.h | 39 -
ldid2/libplist/src/strbuf.h | 34 -
ldid2/libplist/src/time64.c | 812 -
ldid2/libplist/src/time64.h | 81 -
ldid2/libplist/src/time64_limits.h | 97 -
ldid2/libplist/src/xplist.c | 1451 -
ldid2/libplist/test/Makefile.am | 83 -
ldid2/libplist/test/amp.test | 14 -
ldid2/libplist/test/bigarray.test | 15 -
ldid2/libplist/test/cdata.test | 12 -
ldid2/libplist/test/data/1.plist | 35 -
ldid2/libplist/test/data/2.plist | 100 -
ldid2/libplist/test/data/3.plist | 420 -
ldid2/libplist/test/data/4.plist | 5037 --
ldid2/libplist/test/data/5.plist | 55053 ----------------
ldid2/libplist/test/data/6.plist | 4006 --
ldid2/libplist/test/data/7.plist | 14 -
ldid2/libplist/test/data/amp.plist | 6 -
ldid2/libplist/test/data/cdata.plist | 6 -
ldid2/libplist/test/data/dictref1byte.bplist | Bin 50 -> 0 bytes
ldid2/libplist/test/data/dictref2bytes.bplist | Bin 52 -> 0 bytes
ldid2/libplist/test/data/dictref3bytes.bplist | Bin 54 -> 0 bytes
ldid2/libplist/test/data/dictref4bytes.bplist | Bin 56 -> 0 bytes
ldid2/libplist/test/data/dictref5bytes.bplist | Bin 58 -> 0 bytes
ldid2/libplist/test/data/dictref6bytes.bplist | Bin 60 -> 0 bytes
ldid2/libplist/test/data/dictref7bytes.bplist | Bin 62 -> 0 bytes
ldid2/libplist/test/data/dictref8bytes.bplist | Bin 64 -> 0 bytes
ldid2/libplist/test/data/empty_keys.plist | 8 -
ldid2/libplist/test/data/entities.plist | 57 -
ldid2/libplist/test/data/hex.plist | 5 -
ldid2/libplist/test/data/invalid_tag.plist | 6 -
.../libplist/test/data/malformed_dict.bplist | Bin 77 -> 0 bytes
ldid2/libplist/test/data/off1byte.bplist | Bin 50 -> 0 bytes
ldid2/libplist/test/data/off2bytes.bplist | Bin 53 -> 0 bytes
ldid2/libplist/test/data/off3bytes.bplist | Bin 56 -> 0 bytes
ldid2/libplist/test/data/off4bytes.bplist | Bin 59 -> 0 bytes
ldid2/libplist/test/data/off5bytes.bplist | Bin 62 -> 0 bytes
ldid2/libplist/test/data/off6bytes.bplist | Bin 65 -> 0 bytes
ldid2/libplist/test/data/off7bytes.bplist | Bin 68 -> 0 bytes
ldid2/libplist/test/data/off8bytes.bplist | Bin 71 -> 0 bytes
ldid2/libplist/test/data/offxml.plist | 8 -
ldid2/libplist/test/data/order.bplist | Bin 77 -> 0 bytes
ldid2/libplist/test/data/order.plist | 27 -
ldid2/libplist/test/data/recursion.bplist | Bin 60 -> 0 bytes
ldid2/libplist/test/data/signed.bplist | Bin 50 -> 0 bytes
ldid2/libplist/test/data/signed.plist | 5 -
.../libplist/test/data/signedunsigned.bplist | Bin 113 -> 0 bytes
ldid2/libplist/test/data/signedunsigned.plist | 11 -
ldid2/libplist/test/data/unsigned.bplist | Bin 58 -> 0 bytes
ldid2/libplist/test/data/unsigned.plist | 5 -
ldid2/libplist/test/dates.test | 15 -
ldid2/libplist/test/empty.test | 15 -
ldid2/libplist/test/empty_keys.test | 12 -
ldid2/libplist/test/entities.test | 12 -
ldid2/libplist/test/hex.test | 12 -
ldid2/libplist/test/huge.test | 15 -
ldid2/libplist/test/invalid_tag.test | 14 -
ldid2/libplist/test/large.test | 15 -
ldid2/libplist/test/malformed_dict.test | 11 -
ldid2/libplist/test/medium.test | 15 -
ldid2/libplist/test/offsetsize.test | 12 -
ldid2/libplist/test/order.test | 13 -
ldid2/libplist/test/plist_cmp.c | 158 -
ldid2/libplist/test/plist_test.c | 135 -
ldid2/libplist/test/recursion.test | 11 -
ldid2/libplist/test/refsize.test | 12 -
ldid2/libplist/test/signedunsigned1.test | 23 -
ldid2/libplist/test/signedunsigned2.test | 23 -
ldid2/libplist/test/signedunsigned3.test | 23 -
ldid2/libplist/test/small.test | 15 -
ldid2/libplist/test/timezone1.test | 17 -
ldid2/libplist/test/timezone2.test | 21 -
ldid2/libplist/tools/Makefile.am | 7 -
ldid2/libplist/tools/plistutil.c | 185 -
ldid2/lookup2.c | 416 -
ldid2/make.sh | 65 -
ldid2/plist.sh | 2 -
ldid2/sha1.h | 64 -
ldid2/version.sh | 2 -
215 files changed, 94893 deletions(-)
delete mode 100644 ldid2/.gitignore
delete mode 100644 ldid2/.gitmodules
delete mode 100644 ldid2/COPYING
delete mode 100644 ldid2/control
delete mode 100755 ldid2/control.sh
delete mode 100755 ldid2/deb.sh
delete mode 100755 ldid2/ios.sh
delete mode 100644 ldid2/ldid.cpp
delete mode 100644 ldid2/ldid.hpp
delete mode 100644 ldid2/libplist/.gitignore
delete mode 100644 ldid2/libplist/AUTHORS
delete mode 100644 ldid2/libplist/COPYING
delete mode 100644 ldid2/libplist/COPYING.LESSER
delete mode 100644 ldid2/libplist/Makefile.am
delete mode 100644 ldid2/libplist/NEWS
delete mode 100644 ldid2/libplist/README.md
delete mode 100755 ldid2/libplist/autogen.sh
delete mode 100644 ldid2/libplist/configure.ac
delete mode 100644 ldid2/libplist/cython/Makefile.am
delete mode 100644 ldid2/libplist/cython/plist.pxd
delete mode 100644 ldid2/libplist/cython/plist.pyx
delete mode 100644 ldid2/libplist/cython/plist_util.c
delete mode 100644 ldid2/libplist/cython/plist_util.h
delete mode 100644 ldid2/libplist/doxygen.cfg.in
delete mode 100644 ldid2/libplist/fuzz/Makefile.am
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-4766291097288704
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-4930725262393344
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-5421965105954816
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-5556177727389696
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-6557963011489792
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/clusterfuzz-testcase-6605859144597504
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-0ce4dd483b645bc05ec45a97d285dcf1933ee840
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-0d59cdcb5c3416c2790612b78a631ce9f5622800
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-17d635ab460fef74df1ac7561f1253533a6359c5
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-33a67313fa7864cd627ef92d12017a127d342f28
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-39f1347115f8fe9ac25cdc9332e3fc5cd32c7f7b
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-4bd78175fe01d07c5ee90104fbc68d95dd092210
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-4c5404453bb7425aef9b953a5f6f3f0afcc48392
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-52775e25f6af20af351cd616834e602fc988a032
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-6d1399685b745d3d49fadc91072fabcdde8d16fa
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-94b3725900d63c6258448fd757559c81002de9c9
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-a47195acbabc3f5b2cda9c6ebda42f2afc1cc5af
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-ce852bae6aeeffc4698a93660236f1b995ce966e
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-daddb6e82e3d1ed76e20e4131462f5247a6fb131
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-f21be4ebce7f9c337bf96b93cec7e252f5c75a21
delete mode 100644 ldid2/libplist/fuzz/bplist-crashes/crash-f779dafccc0164684d1a264976e56037188b40e2
delete mode 100644 ldid2/libplist/fuzz/bplist-leaks/leak-96fb453b3ba18d31e164831795a708183b5a0dac
delete mode 100644 ldid2/libplist/fuzz/bplist-leaks/leak-acb3c00a83d7635638a476a4e70fc1f1caa1a5b1
delete mode 100644 ldid2/libplist/fuzz/bplist-leaks/leak-fe2cd4b1f67e0c9b21e6225a4fb4ca19eab80074
delete mode 100644 ldid2/libplist/fuzz/bplist.dict
delete mode 100644 ldid2/libplist/fuzz/bplist_fuzzer.cc
delete mode 100644 ldid2/libplist/fuzz/bplist_fuzzer.options
delete mode 100755 ldid2/libplist/fuzz/fuzzers.test
delete mode 100755 ldid2/libplist/fuzz/init-fuzzers.sh
delete mode 100755 ldid2/libplist/fuzz/test-fuzzers.sh
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-4516959125241856
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-4663876528373760
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-5799076113154048
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-5922404220010496
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6015098361479168
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6043836860071936
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6047509906456576
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/clusterfuzz-testcase-6482601374121984
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-09788d7acb46b4b177422f9c4ee54556a3ad1f17
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-155c60d5c4b2778110fb4a633caa7d64eb9b99c1
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-348c909a0b3532977185f551eb5d2ed04e694883
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-7bc172e27a2b1d4fcaf031f59d1f08fb83081e4a
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-80c28b0e2a446665e68927dd4441c10c9a68e64e
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-8acf177da60ecf13c36d0da1b8e25de891980ea6
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-94276cf69a50e78dd6cdf079c208cb80f357cd33
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-9ddb891a0ec42401eb4629e6b99e01aef7909eb9
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-a8b44e1f5be4f75f00a937016ec5405bce77a0f9
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
delete mode 100644 ldid2/libplist/fuzz/xplist-crashes/crash-f03c680ee1c4d84c28e731752df77a61e213a24d
delete mode 100644 ldid2/libplist/fuzz/xplist-leaks/clusterfuzz-testcase-4634751103139840
delete mode 100644 ldid2/libplist/fuzz/xplist-leaks/clusterfuzz-testcase-6056412121661440
delete mode 100644 ldid2/libplist/fuzz/xplist-leaks/leak-47b0a9f21d3affab6cfc898e5140bb53265ada07
delete mode 100644 ldid2/libplist/fuzz/xplist-leaks/leak-4c81aae70b20d9b9408b78d40999a54205bdcfb7
delete mode 100644 ldid2/libplist/fuzz/xplist-leaks/leak-53bc466851eda790bd891733da5db0a7482886bf
delete mode 100644 ldid2/libplist/fuzz/xplist.dict
delete mode 100644 ldid2/libplist/fuzz/xplist_fuzzer.cc
delete mode 100644 ldid2/libplist/fuzz/xplist_fuzzer.options
delete mode 100644 ldid2/libplist/include/Makefile.am
delete mode 100644 ldid2/libplist/include/plist/Array.h
delete mode 100644 ldid2/libplist/include/plist/Boolean.h
delete mode 100644 ldid2/libplist/include/plist/Data.h
delete mode 100644 ldid2/libplist/include/plist/Date.h
delete mode 100644 ldid2/libplist/include/plist/Dictionary.h
delete mode 100644 ldid2/libplist/include/plist/Integer.h
delete mode 100644 ldid2/libplist/include/plist/Key.h
delete mode 100644 ldid2/libplist/include/plist/Node.h
delete mode 100644 ldid2/libplist/include/plist/Real.h
delete mode 100644 ldid2/libplist/include/plist/String.h
delete mode 100644 ldid2/libplist/include/plist/Structure.h
delete mode 100644 ldid2/libplist/include/plist/Uid.h
delete mode 100644 ldid2/libplist/include/plist/plist++.h
delete mode 100644 ldid2/libplist/include/plist/plist.h
delete mode 100644 ldid2/libplist/libcnary/COPYING
delete mode 100644 ldid2/libplist/libcnary/Makefile.am
delete mode 100644 ldid2/libplist/libcnary/README
delete mode 100644 ldid2/libplist/libcnary/cnary.c
delete mode 100644 ldid2/libplist/libcnary/include/node.h
delete mode 100644 ldid2/libplist/libcnary/include/node_list.h
delete mode 100644 ldid2/libplist/libcnary/include/object.h
delete mode 100644 ldid2/libplist/libcnary/node.c
delete mode 100644 ldid2/libplist/libcnary/node_list.c
delete mode 100644 ldid2/libplist/m4/ac_pkg_cython.m4
delete mode 100644 ldid2/libplist/m4/as-compiler-flag.m4
delete mode 100644 ldid2/libplist/m4/ax_pthread.m4
delete mode 100644 ldid2/libplist/m4/ax_python_devel.m4
delete mode 100644 ldid2/libplist/m4/cython_python.m4
delete mode 100644 ldid2/libplist/src/Array.cpp
delete mode 100644 ldid2/libplist/src/Boolean.cpp
delete mode 100644 ldid2/libplist/src/Data.cpp
delete mode 100644 ldid2/libplist/src/Date.cpp
delete mode 100644 ldid2/libplist/src/Dictionary.cpp
delete mode 100644 ldid2/libplist/src/Integer.cpp
delete mode 100644 ldid2/libplist/src/Key.cpp
delete mode 100644 ldid2/libplist/src/Makefile.am
delete mode 100644 ldid2/libplist/src/Node.cpp
delete mode 100644 ldid2/libplist/src/Real.cpp
delete mode 100644 ldid2/libplist/src/String.cpp
delete mode 100644 ldid2/libplist/src/Structure.cpp
delete mode 100644 ldid2/libplist/src/Uid.cpp
delete mode 100644 ldid2/libplist/src/base64.c
delete mode 100644 ldid2/libplist/src/base64.h
delete mode 100644 ldid2/libplist/src/bplist.c
delete mode 100644 ldid2/libplist/src/bytearray.c
delete mode 100644 ldid2/libplist/src/bytearray.h
delete mode 100644 ldid2/libplist/src/hashtable.c
delete mode 100644 ldid2/libplist/src/hashtable.h
delete mode 100644 ldid2/libplist/src/libplist++.pc.in
delete mode 100644 ldid2/libplist/src/libplist.pc.in
delete mode 100644 ldid2/libplist/src/plist.c
delete mode 100644 ldid2/libplist/src/plist.h
delete mode 100644 ldid2/libplist/src/ptrarray.c
delete mode 100644 ldid2/libplist/src/ptrarray.h
delete mode 100644 ldid2/libplist/src/strbuf.h
delete mode 100644 ldid2/libplist/src/time64.c
delete mode 100644 ldid2/libplist/src/time64.h
delete mode 100644 ldid2/libplist/src/time64_limits.h
delete mode 100644 ldid2/libplist/src/xplist.c
delete mode 100644 ldid2/libplist/test/Makefile.am
delete mode 100755 ldid2/libplist/test/amp.test
delete mode 100755 ldid2/libplist/test/bigarray.test
delete mode 100755 ldid2/libplist/test/cdata.test
delete mode 100644 ldid2/libplist/test/data/1.plist
delete mode 100644 ldid2/libplist/test/data/2.plist
delete mode 100644 ldid2/libplist/test/data/3.plist
delete mode 100644 ldid2/libplist/test/data/4.plist
delete mode 100644 ldid2/libplist/test/data/5.plist
delete mode 100644 ldid2/libplist/test/data/6.plist
delete mode 100644 ldid2/libplist/test/data/7.plist
delete mode 100644 ldid2/libplist/test/data/amp.plist
delete mode 100644 ldid2/libplist/test/data/cdata.plist
delete mode 100644 ldid2/libplist/test/data/dictref1byte.bplist
delete mode 100644 ldid2/libplist/test/data/dictref2bytes.bplist
delete mode 100644 ldid2/libplist/test/data/dictref3bytes.bplist
delete mode 100644 ldid2/libplist/test/data/dictref4bytes.bplist
delete mode 100644 ldid2/libplist/test/data/dictref5bytes.bplist
delete mode 100644 ldid2/libplist/test/data/dictref6bytes.bplist
delete mode 100644 ldid2/libplist/test/data/dictref7bytes.bplist
delete mode 100644 ldid2/libplist/test/data/dictref8bytes.bplist
delete mode 100644 ldid2/libplist/test/data/empty_keys.plist
delete mode 100644 ldid2/libplist/test/data/entities.plist
delete mode 100644 ldid2/libplist/test/data/hex.plist
delete mode 100644 ldid2/libplist/test/data/invalid_tag.plist
delete mode 100644 ldid2/libplist/test/data/malformed_dict.bplist
delete mode 100644 ldid2/libplist/test/data/off1byte.bplist
delete mode 100644 ldid2/libplist/test/data/off2bytes.bplist
delete mode 100644 ldid2/libplist/test/data/off3bytes.bplist
delete mode 100644 ldid2/libplist/test/data/off4bytes.bplist
delete mode 100644 ldid2/libplist/test/data/off5bytes.bplist
delete mode 100644 ldid2/libplist/test/data/off6bytes.bplist
delete mode 100644 ldid2/libplist/test/data/off7bytes.bplist
delete mode 100644 ldid2/libplist/test/data/off8bytes.bplist
delete mode 100644 ldid2/libplist/test/data/offxml.plist
delete mode 100644 ldid2/libplist/test/data/order.bplist
delete mode 100644 ldid2/libplist/test/data/order.plist
delete mode 100644 ldid2/libplist/test/data/recursion.bplist
delete mode 100644 ldid2/libplist/test/data/signed.bplist
delete mode 100644 ldid2/libplist/test/data/signed.plist
delete mode 100644 ldid2/libplist/test/data/signedunsigned.bplist
delete mode 100644 ldid2/libplist/test/data/signedunsigned.plist
delete mode 100644 ldid2/libplist/test/data/unsigned.bplist
delete mode 100644 ldid2/libplist/test/data/unsigned.plist
delete mode 100755 ldid2/libplist/test/dates.test
delete mode 100755 ldid2/libplist/test/empty.test
delete mode 100755 ldid2/libplist/test/empty_keys.test
delete mode 100755 ldid2/libplist/test/entities.test
delete mode 100755 ldid2/libplist/test/hex.test
delete mode 100755 ldid2/libplist/test/huge.test
delete mode 100755 ldid2/libplist/test/invalid_tag.test
delete mode 100755 ldid2/libplist/test/large.test
delete mode 100755 ldid2/libplist/test/malformed_dict.test
delete mode 100755 ldid2/libplist/test/medium.test
delete mode 100755 ldid2/libplist/test/offsetsize.test
delete mode 100755 ldid2/libplist/test/order.test
delete mode 100644 ldid2/libplist/test/plist_cmp.c
delete mode 100644 ldid2/libplist/test/plist_test.c
delete mode 100755 ldid2/libplist/test/recursion.test
delete mode 100755 ldid2/libplist/test/refsize.test
delete mode 100755 ldid2/libplist/test/signedunsigned1.test
delete mode 100755 ldid2/libplist/test/signedunsigned2.test
delete mode 100755 ldid2/libplist/test/signedunsigned3.test
delete mode 100755 ldid2/libplist/test/small.test
delete mode 100755 ldid2/libplist/test/timezone1.test
delete mode 100755 ldid2/libplist/test/timezone2.test
delete mode 100644 ldid2/libplist/tools/Makefile.am
delete mode 100644 ldid2/libplist/tools/plistutil.c
delete mode 100644 ldid2/lookup2.c
delete mode 100755 ldid2/make.sh
delete mode 100755 ldid2/plist.sh
delete mode 100644 ldid2/sha1.h
delete mode 100755 ldid2/version.sh
diff --git a/ldid2/.gitignore b/ldid2/.gitignore
deleted file mode 100644
index 178d6ef..0000000
--- a/ldid2/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-ios
-out
-ldid
-ldid.deb
-debs
-*.o
-_
diff --git a/ldid2/.gitmodules b/ldid2/.gitmodules
deleted file mode 100644
index 5b41a81..0000000
--- a/ldid2/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "libplist"]
- path = libplist
- url = https://github.com/libimobiledevice/libplist.git
diff --git a/ldid2/COPYING b/ldid2/COPYING
deleted file mode 100644
index dba13ed..0000000
--- a/ldid2/COPYING
+++ /dev/null
@@ -1,661 +0,0 @@
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-.
diff --git a/ldid2/control b/ldid2/control
deleted file mode 100644
index 9accbb8..0000000
--- a/ldid2/control
+++ /dev/null
@@ -1,11 +0,0 @@
-Package: ldid
-Priority: optional
-Section: Development
-Maintainer: Jay Freeman (saurik)
-Architecture: iphoneos-arm
-Version:
-Description: pseudo-codesign Mach-O files
-Name: Link Identity Editor
-Author: Jay Freeman (saurik)
-Depiction: http://cydia.saurik.com/info/ldid/
-Tag: purpose::console, role::developer
diff --git a/ldid2/control.sh b/ldid2/control.sh
deleted file mode 100755
index 7a11d56..0000000
--- a/ldid2/control.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-dir=$1
-dir=${dir:=_}
-sed -e "s@^\(Version:.*\)@\1$(./version.sh)@" control
-echo "Installed-Size: $(du -s "${dir}" | cut -f 1)"
diff --git a/ldid2/deb.sh b/ldid2/deb.sh
deleted file mode 100755
index 3fb31a5..0000000
--- a/ldid2/deb.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-rm -rf _
-mkdir -p _/usr/bin
-cp -a ios/ldid _/usr/bin/ldid
-mkdir -p _/DEBIAN
-./control.sh _ >_/DEBIAN/control
-mkdir -p debs
-ln -sf debs/ldid_$(./version.sh)_iphoneos-arm.deb ldid.deb
-dpkg-deb -b _ ldid.deb
-readlink ldid.deb
diff --git a/ldid2/ios.sh b/ldid2/ios.sh
deleted file mode 100755
index fb7c409..0000000
--- a/ldid2/ios.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-./make.sh true -Lsysroot/usr/lib
diff --git a/ldid2/ldid.cpp b/ldid2/ldid.cpp
deleted file mode 100644
index 8700c72..0000000
--- a/ldid2/ldid.cpp
+++ /dev/null
@@ -1,2788 +0,0 @@
-/* ldid - (Mach-O) Link-Loader Identity Editor
- * Copyright (C) 2007-2015 Jay Freeman (saurik)
-*/
-
-/* GNU Affero General Public License, Version 3 {{{ */
-/*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
-
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
-**/
-/* }}} */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#ifndef LDID_NOSMIME
-#include
-#include
-#include
-#include
-#endif
-
-#ifdef __APPLE__
-#include
-
-#define LDID_SHA1_DIGEST_LENGTH CC_SHA1_DIGEST_LENGTH
-#define LDID_SHA1 CC_SHA1
-#define LDID_SHA1_CTX CC_SHA1_CTX
-#define LDID_SHA1_Init CC_SHA1_Init
-#define LDID_SHA1_Update CC_SHA1_Update
-#define LDID_SHA1_Final CC_SHA1_Final
-
-#define LDID_SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH
-#define LDID_SHA256 CC_SHA256
-#define LDID_SHA256_CTX CC_SHA256_CTX
-#define LDID_SHA256_Init CC_SHA256_Init
-#define LDID_SHA256_Update CC_SHA256_Update
-#define LDID_SHA256_Final CC_SHA256_Final
-#else
-#include
-
-#define LDID_SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
-#define LDID_SHA1 SHA1
-#define LDID_SHA1_CTX SHA_CTX
-#define LDID_SHA1_Init SHA1_Init
-#define LDID_SHA1_Update SHA1_Update
-#define LDID_SHA1_Final SHA1_Final
-
-#define LDID_SHA256_DIGEST_LENGTH SHA256_DIGEST_LENGTH
-#define LDID_SHA256 SHA256
-#define LDID_SHA256_CTX SHA256_CTX
-#define LDID_SHA256_Init SHA256_Init
-#define LDID_SHA256_Update SHA256_Update
-#define LDID_SHA256_Final SHA256_Final
-#endif
-
-#ifndef LDID_NOPLIST
-#include
-#endif
-
-#include "ldid.hpp"
-
-#define _assert___(line) \
- #line
-#define _assert__(line) \
- _assert___(line)
-
-#ifdef __EXCEPTIONS
-#define _assert_(expr, format, ...) \
- do if (!(expr)) { \
- fprintf(stderr, "%s(%u): _assert(): " format "\n", __FILE__, __LINE__, ## __VA_ARGS__); \
- throw __FILE__ "(" _assert__(__LINE__) "): _assert(" #expr ")"; \
- } while (false)
-#else
-// XXX: this is not acceptable
-#define _assert_(expr, format, ...) \
- do if (!(expr)) { \
- fprintf(stderr, "%s(%u): _assert(): " format "\n", __FILE__, __LINE__, ## __VA_ARGS__); \
- exit(-1); \
- } while (false)
-#endif
-
-#define _assert(expr) \
- _assert_(expr, "%s", #expr)
-
-#define _syscall(expr, ...) [&] { for (;;) { \
- auto _value(expr); \
- if ((long) _value != -1) \
- return _value; \
- int error(errno); \
- if (error == EINTR) \
- continue; \
- /* XXX: EINTR is included in this list to fix g++ */ \
- for (auto success : (long[]) {EINTR, __VA_ARGS__}) \
- if (error == success) \
- return (decltype(expr)) -success; \
- _assert_(false, "errno=%u", error); \
-} }()
-
-#define _trace() \
- fprintf(stderr, "_trace(%s:%u): %s\n", __FILE__, __LINE__, __FUNCTION__)
-
-#define _not(type) \
- ((type) ~ (type) 0)
-
-#define _packed \
- __attribute__((packed))
-
-template
-struct Iterator_ {
- typedef typename Type_::const_iterator Result;
-};
-
-#define _foreach(item, list) \
- for (bool _stop(true); _stop; ) \
- for (const __typeof__(list) &_list = (list); _stop; _stop = false) \
- for (Iterator_<__typeof__(list)>::Result _item = _list.begin(); _item != _list.end(); ++_item) \
- for (bool _suck(true); _suck; _suck = false) \
- for (const __typeof__(*_item) &item = *_item; _suck; _suck = false)
-
-class _Scope {
-};
-
-template
-class Scope :
- public _Scope
-{
- private:
- Function_ function_;
-
- public:
- Scope(const Function_ &function) :
- function_(function)
- {
- }
-
- ~Scope() {
- function_();
- }
-};
-
-template
-Scope _scope(const Function_ &function) {
- return Scope(function);
-}
-
-#define _scope__(counter, function) \
- __attribute__((__unused__)) \
- const _Scope &_scope ## counter(_scope([&]function))
-#define _scope_(counter, function) \
- _scope__(counter, function)
-#define _scope(function) \
- _scope_(__COUNTER__, function)
-
-#define CPU_ARCH_MASK uint32_t(0xff000000)
-#define CPU_ARCH_ABI64 uint32_t(0x01000000)
-
-#define CPU_TYPE_ANY uint32_t(-1)
-#define CPU_TYPE_VAX uint32_t( 1)
-#define CPU_TYPE_MC680x0 uint32_t( 6)
-#define CPU_TYPE_X86 uint32_t( 7)
-#define CPU_TYPE_MC98000 uint32_t(10)
-#define CPU_TYPE_HPPA uint32_t(11)
-#define CPU_TYPE_ARM uint32_t(12)
-#define CPU_TYPE_MC88000 uint32_t(13)
-#define CPU_TYPE_SPARC uint32_t(14)
-#define CPU_TYPE_I860 uint32_t(15)
-#define CPU_TYPE_POWERPC uint32_t(18)
-
-#define CPU_TYPE_I386 CPU_TYPE_X86
-
-#define CPU_TYPE_ARM64 (CPU_ARCH_ABI64 | CPU_TYPE_ARM)
-#define CPU_TYPE_POWERPC64 (CPU_ARCH_ABI64 | CPU_TYPE_POWERPC)
-#define CPU_TYPE_X86_64 (CPU_ARCH_ABI64 | CPU_TYPE_X86)
-
-struct fat_header {
- uint32_t magic;
- uint32_t nfat_arch;
-} _packed;
-
-#define FAT_MAGIC 0xcafebabe
-#define FAT_CIGAM 0xbebafeca
-
-struct fat_arch {
- uint32_t cputype;
- uint32_t cpusubtype;
- uint32_t offset;
- uint32_t size;
- uint32_t align;
-} _packed;
-
-struct mach_header {
- uint32_t magic;
- uint32_t cputype;
- uint32_t cpusubtype;
- uint32_t filetype;
- uint32_t ncmds;
- uint32_t sizeofcmds;
- uint32_t flags;
-} _packed;
-
-#define MH_MAGIC 0xfeedface
-#define MH_CIGAM 0xcefaedfe
-
-#define MH_MAGIC_64 0xfeedfacf
-#define MH_CIGAM_64 0xcffaedfe
-
-#define MH_DYLDLINK 0x4
-
-#define MH_OBJECT 0x1
-#define MH_EXECUTE 0x2
-#define MH_DYLIB 0x6
-#define MH_BUNDLE 0x8
-#define MH_DYLIB_STUB 0x9
-
-struct load_command {
- uint32_t cmd;
- uint32_t cmdsize;
-} _packed;
-
-#define LC_REQ_DYLD uint32_t(0x80000000)
-
-#define LC_SEGMENT uint32_t(0x01)
-#define LC_SYMTAB uint32_t(0x02)
-#define LC_DYSYMTAB uint32_t(0x0b)
-#define LC_LOAD_DYLIB uint32_t(0x0c)
-#define LC_ID_DYLIB uint32_t(0x0d)
-#define LC_SEGMENT_64 uint32_t(0x19)
-#define LC_UUID uint32_t(0x1b)
-#define LC_CODE_SIGNATURE uint32_t(0x1d)
-#define LC_SEGMENT_SPLIT_INFO uint32_t(0x1e)
-#define LC_REEXPORT_DYLIB uint32_t(0x1f | LC_REQ_DYLD)
-#define LC_ENCRYPTION_INFO uint32_t(0x21)
-#define LC_DYLD_INFO uint32_t(0x22)
-#define LC_DYLD_INFO_ONLY uint32_t(0x22 | LC_REQ_DYLD)
-#define LC_ENCRYPTION_INFO_64 uint32_t(0x2c)
-
-union Version {
- struct {
- uint8_t patch;
- uint8_t minor;
- uint16_t major;
- } _packed;
-
- uint32_t value;
-};
-
-struct dylib {
- uint32_t name;
- uint32_t timestamp;
- uint32_t current_version;
- uint32_t compatibility_version;
-} _packed;
-
-struct dylib_command {
- uint32_t cmd;
- uint32_t cmdsize;
- struct dylib dylib;
-} _packed;
-
-struct uuid_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint8_t uuid[16];
-} _packed;
-
-struct symtab_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t symoff;
- uint32_t nsyms;
- uint32_t stroff;
- uint32_t strsize;
-} _packed;
-
-struct dyld_info_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t rebase_off;
- uint32_t rebase_size;
- uint32_t bind_off;
- uint32_t bind_size;
- uint32_t weak_bind_off;
- uint32_t weak_bind_size;
- uint32_t lazy_bind_off;
- uint32_t lazy_bind_size;
- uint32_t export_off;
- uint32_t export_size;
-} _packed;
-
-struct dysymtab_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t ilocalsym;
- uint32_t nlocalsym;
- uint32_t iextdefsym;
- uint32_t nextdefsym;
- uint32_t iundefsym;
- uint32_t nundefsym;
- uint32_t tocoff;
- uint32_t ntoc;
- uint32_t modtaboff;
- uint32_t nmodtab;
- uint32_t extrefsymoff;
- uint32_t nextrefsyms;
- uint32_t indirectsymoff;
- uint32_t nindirectsyms;
- uint32_t extreloff;
- uint32_t nextrel;
- uint32_t locreloff;
- uint32_t nlocrel;
-} _packed;
-
-struct dylib_table_of_contents {
- uint32_t symbol_index;
- uint32_t module_index;
-} _packed;
-
-struct dylib_module {
- uint32_t module_name;
- uint32_t iextdefsym;
- uint32_t nextdefsym;
- uint32_t irefsym;
- uint32_t nrefsym;
- uint32_t ilocalsym;
- uint32_t nlocalsym;
- uint32_t iextrel;
- uint32_t nextrel;
- uint32_t iinit_iterm;
- uint32_t ninit_nterm;
- uint32_t objc_module_info_addr;
- uint32_t objc_module_info_size;
-} _packed;
-
-struct dylib_reference {
- uint32_t isym:24;
- uint32_t flags:8;
-} _packed;
-
-struct relocation_info {
- int32_t r_address;
- uint32_t r_symbolnum:24;
- uint32_t r_pcrel:1;
- uint32_t r_length:2;
- uint32_t r_extern:1;
- uint32_t r_type:4;
-} _packed;
-
-struct nlist {
- union {
- char *n_name;
- int32_t n_strx;
- } n_un;
-
- uint8_t n_type;
- uint8_t n_sect;
- uint8_t n_desc;
- uint32_t n_value;
-} _packed;
-
-struct segment_command {
- uint32_t cmd;
- uint32_t cmdsize;
- char segname[16];
- uint32_t vmaddr;
- uint32_t vmsize;
- uint32_t fileoff;
- uint32_t filesize;
- uint32_t maxprot;
- uint32_t initprot;
- uint32_t nsects;
- uint32_t flags;
-} _packed;
-
-struct segment_command_64 {
- uint32_t cmd;
- uint32_t cmdsize;
- char segname[16];
- uint64_t vmaddr;
- uint64_t vmsize;
- uint64_t fileoff;
- uint64_t filesize;
- uint32_t maxprot;
- uint32_t initprot;
- uint32_t nsects;
- uint32_t flags;
-} _packed;
-
-struct section {
- char sectname[16];
- char segname[16];
- uint32_t addr;
- uint32_t size;
- uint32_t offset;
- uint32_t align;
- uint32_t reloff;
- uint32_t nreloc;
- uint32_t flags;
- uint32_t reserved1;
- uint32_t reserved2;
-} _packed;
-
-struct section_64 {
- char sectname[16];
- char segname[16];
- uint64_t addr;
- uint64_t size;
- uint32_t offset;
- uint32_t align;
- uint32_t reloff;
- uint32_t nreloc;
- uint32_t flags;
- uint32_t reserved1;
- uint32_t reserved2;
- uint32_t reserved3;
-} _packed;
-
-struct linkedit_data_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t dataoff;
- uint32_t datasize;
-} _packed;
-
-struct encryption_info_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t cryptoff;
- uint32_t cryptsize;
- uint32_t cryptid;
-} _packed;
-
-#define BIND_OPCODE_MASK 0xf0
-#define BIND_IMMEDIATE_MASK 0x0f
-#define BIND_OPCODE_DONE 0x00
-#define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10
-#define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20
-#define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30
-#define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40
-#define BIND_OPCODE_SET_TYPE_IMM 0x50
-#define BIND_OPCODE_SET_ADDEND_SLEB 0x60
-#define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70
-#define BIND_OPCODE_ADD_ADDR_ULEB 0x80
-#define BIND_OPCODE_DO_BIND 0x90
-#define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xa0
-#define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xb0
-#define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xc0
-
-static auto dummy([](double) {});
-
-static std::streamsize read(std::streambuf &stream, void *data, size_t size) {
- auto writ(stream.sgetn(static_cast(data), size));
- _assert(writ >= 0);
- return writ;
-}
-
-static inline void get(std::streambuf &stream, void *data, size_t size) {
- _assert(read(stream, data, size) == size);
-}
-
-static inline void put(std::streambuf &stream, const void *data, size_t size) {
- _assert(stream.sputn(static_cast(data), size) == size);
-}
-
-static inline void put(std::streambuf &stream, const void *data, size_t size, const ldid::Functor &percent) {
- percent(0);
- for (size_t total(0); total != size;) {
- auto writ(std::min(size - total, size_t(4096 * 4)));
- _assert(stream.sputn(static_cast(data) + total, writ) == writ);
- total += writ;
- percent(double(total) / size);
- }
-}
-
-static size_t most(std::streambuf &stream, void *data, size_t size) {
- size_t total(size);
- while (size > 0)
- if (auto writ = read(stream, data, size))
- size -= writ;
- else break;
- return total - size;
-}
-
-static inline void pad(std::streambuf &stream, size_t size) {
- char padding[size];
- memset(padding, 0, size);
- put(stream, padding, size);
-}
-
-template
-Type_ Align(Type_ value, size_t align) {
- value += align - 1;
- value /= align;
- value *= align;
- return value;
-}
-
-static const uint8_t PageShift_(0x0c);
-static const uint32_t PageSize_(1 << PageShift_);
-
-static inline uint16_t Swap_(uint16_t value) {
- return
- ((value >> 8) & 0x00ff) |
- ((value << 8) & 0xff00);
-}
-
-static inline uint32_t Swap_(uint32_t value) {
- value = ((value >> 8) & 0x00ff00ff) |
- ((value << 8) & 0xff00ff00);
- value = ((value >> 16) & 0x0000ffff) |
- ((value << 16) & 0xffff0000);
- return value;
-}
-
-static inline uint64_t Swap_(uint64_t value) {
- value = (value & 0x00000000ffffffff) << 32 | (value & 0xffffffff00000000) >> 32;
- value = (value & 0x0000ffff0000ffff) << 16 | (value & 0xffff0000ffff0000) >> 16;
- value = (value & 0x00ff00ff00ff00ff) << 8 | (value & 0xff00ff00ff00ff00) >> 8;
- return value;
-}
-
-static inline int16_t Swap_(int16_t value) {
- return Swap_(static_cast(value));
-}
-
-static inline int32_t Swap_(int32_t value) {
- return Swap_(static_cast(value));
-}
-
-static inline int64_t Swap_(int64_t value) {
- return Swap_(static_cast(value));
-}
-
-static bool little_(true);
-
-static inline uint16_t Swap(uint16_t value) {
- return little_ ? Swap_(value) : value;
-}
-
-static inline uint32_t Swap(uint32_t value) {
- return little_ ? Swap_(value) : value;
-}
-
-static inline uint64_t Swap(uint64_t value) {
- return little_ ? Swap_(value) : value;
-}
-
-static inline int16_t Swap(int16_t value) {
- return Swap(static_cast(value));
-}
-
-static inline int32_t Swap(int32_t value) {
- return Swap(static_cast(value));
-}
-
-static inline int64_t Swap(int64_t value) {
- return Swap(static_cast(value));
-}
-
-class Swapped {
- protected:
- bool swapped_;
-
- Swapped() :
- swapped_(false)
- {
- }
-
- public:
- Swapped(bool swapped) :
- swapped_(swapped)
- {
- }
-
- template
- Type_ Swap(Type_ value) const {
- return swapped_ ? Swap_(value) : value;
- }
-};
-
-class Data :
- public Swapped
-{
- private:
- void *base_;
- size_t size_;
-
- public:
- Data(void *base, size_t size) :
- base_(base),
- size_(size)
- {
- }
-
- void *GetBase() const {
- return base_;
- }
-
- size_t GetSize() const {
- return size_;
- }
-};
-
-class MachHeader :
- public Data
-{
- private:
- bool bits64_;
-
- struct mach_header *mach_header_;
- struct load_command *load_command_;
-
- public:
- MachHeader(void *base, size_t size) :
- Data(base, size)
- {
- mach_header_ = (mach_header *) base;
-
- switch (Swap(mach_header_->magic)) {
- case MH_CIGAM:
- swapped_ = !swapped_;
- case MH_MAGIC:
- bits64_ = false;
- break;
-
- case MH_CIGAM_64:
- swapped_ = !swapped_;
- case MH_MAGIC_64:
- bits64_ = true;
- break;
-
- default:
- _assert(false);
- }
-
- void *post = mach_header_ + 1;
- if (bits64_)
- post = (uint32_t *) post + 1;
- load_command_ = (struct load_command *) post;
-
- _assert(
- Swap(mach_header_->filetype) == MH_EXECUTE ||
- Swap(mach_header_->filetype) == MH_DYLIB ||
- Swap(mach_header_->filetype) == MH_BUNDLE
- );
- }
-
- bool Bits64() const {
- return bits64_;
- }
-
- struct mach_header *operator ->() const {
- return mach_header_;
- }
-
- operator struct mach_header *() const {
- return mach_header_;
- }
-
- uint32_t GetCPUType() const {
- return Swap(mach_header_->cputype);
- }
-
- uint32_t GetCPUSubtype() const {
- return Swap(mach_header_->cpusubtype) & 0xff;
- }
-
- struct load_command *GetLoadCommand() const {
- return load_command_;
- }
-
- std::vector GetLoadCommands() const {
- std::vector load_commands;
-
- struct load_command *load_command = load_command_;
- for (uint32_t cmd = 0; cmd != Swap(mach_header_->ncmds); ++cmd) {
- load_commands.push_back(load_command);
- load_command = (struct load_command *) ((uint8_t *) load_command + Swap(load_command->cmdsize));
- }
-
- return load_commands;
- }
-
- void ForSection(const ldid::Functor &code) const {
- _foreach (load_command, GetLoadCommands())
- switch (Swap(load_command->cmd)) {
- case LC_SEGMENT: {
- auto segment(reinterpret_cast(load_command));
- code(segment->segname, NULL, GetOffset(segment->fileoff), segment->filesize);
- auto section(reinterpret_cast(segment + 1));
- for (uint32_t i(0), e(Swap(segment->nsects)); i != e; ++i, ++section)
- code(segment->segname, section->sectname, GetOffset(segment->fileoff + section->offset), section->size);
- } break;
-
- case LC_SEGMENT_64: {
- auto segment(reinterpret_cast(load_command));
- code(segment->segname, NULL, GetOffset(segment->fileoff), segment->filesize);
- auto section(reinterpret_cast(segment + 1));
- for (uint32_t i(0), e(Swap(segment->nsects)); i != e; ++i, ++section)
- code(segment->segname, section->sectname, GetOffset(segment->fileoff + section->offset), section->size);
- } break;
- }
- }
-
- template
- Target_ *GetOffset(uint32_t offset) const {
- return reinterpret_cast(offset + (uint8_t *) mach_header_);
- }
-};
-
-class FatMachHeader :
- public MachHeader
-{
- private:
- fat_arch *fat_arch_;
-
- public:
- FatMachHeader(void *base, size_t size, fat_arch *fat_arch) :
- MachHeader(base, size),
- fat_arch_(fat_arch)
- {
- }
-
- fat_arch *GetFatArch() const {
- return fat_arch_;
- }
-};
-
-class FatHeader :
- public Data
-{
- private:
- fat_header *fat_header_;
- std::vector mach_headers_;
-
- public:
- FatHeader(void *base, size_t size) :
- Data(base, size)
- {
- fat_header_ = reinterpret_cast(base);
-
- if (Swap(fat_header_->magic) == FAT_CIGAM) {
- swapped_ = !swapped_;
- goto fat;
- } else if (Swap(fat_header_->magic) != FAT_MAGIC) {
- fat_header_ = NULL;
- mach_headers_.push_back(FatMachHeader(base, size, NULL));
- } else fat: {
- size_t fat_narch = Swap(fat_header_->nfat_arch);
- fat_arch *fat_arch = reinterpret_cast(fat_header_ + 1);
- size_t arch;
- for (arch = 0; arch != fat_narch; ++arch) {
- uint32_t arch_offset = Swap(fat_arch->offset);
- uint32_t arch_size = Swap(fat_arch->size);
- mach_headers_.push_back(FatMachHeader((uint8_t *) base + arch_offset, arch_size, fat_arch));
- ++fat_arch;
- }
- }
- }
-
- std::vector &GetMachHeaders() {
- return mach_headers_;
- }
-
- bool IsFat() const {
- return fat_header_ != NULL;
- }
-
- struct fat_header *operator ->() const {
- return fat_header_;
- }
-
- operator struct fat_header *() const {
- return fat_header_;
- }
-};
-
-#define CSMAGIC_REQUIREMENT uint32_t(0xfade0c00)
-#define CSMAGIC_REQUIREMENTS uint32_t(0xfade0c01)
-#define CSMAGIC_CODEDIRECTORY uint32_t(0xfade0c02)
-#define CSMAGIC_EMBEDDED_SIGNATURE uint32_t(0xfade0cc0)
-#define CSMAGIC_EMBEDDED_SIGNATURE_OLD uint32_t(0xfade0b02)
-#define CSMAGIC_EMBEDDED_ENTITLEMENTS uint32_t(0xfade7171)
-#define CSMAGIC_DETACHED_SIGNATURE uint32_t(0xfade0cc1)
-#define CSMAGIC_BLOBWRAPPER uint32_t(0xfade0b01)
-
-#define CSSLOT_CODEDIRECTORY uint32_t(0x00000)
-#define CSSLOT_INFOSLOT uint32_t(0x00001)
-#define CSSLOT_REQUIREMENTS uint32_t(0x00002)
-#define CSSLOT_RESOURCEDIR uint32_t(0x00003)
-#define CSSLOT_APPLICATION uint32_t(0x00004)
-#define CSSLOT_ENTITLEMENTS uint32_t(0x00005)
-#define CSSLOT_ALTERNATE uint32_t(0x01000)
-
-#define CSSLOT_SIGNATURESLOT uint32_t(0x10000)
-
-#define CS_HASHTYPE_SHA160_160 1
-#define CS_HASHTYPE_SHA256_256 2
-#define CS_HASHTYPE_SHA256_160 3
-#define CS_HASHTYPE_SHA386_386 4
-
-struct BlobIndex {
- uint32_t type;
- uint32_t offset;
-} _packed;
-
-struct Blob {
- uint32_t magic;
- uint32_t length;
-} _packed;
-
-struct SuperBlob {
- struct Blob blob;
- uint32_t count;
- struct BlobIndex index[];
-} _packed;
-
-struct CodeDirectory {
- uint32_t version;
- uint32_t flags;
- uint32_t hashOffset;
- uint32_t identOffset;
- uint32_t nSpecialSlots;
- uint32_t nCodeSlots;
- uint32_t codeLimit;
- uint8_t hashSize;
- uint8_t hashType;
- uint8_t spare1;
- uint8_t pageSize;
- uint32_t spare2;
- uint32_t scatterOffset;
- uint32_t teamIDOffset;
- uint32_t spare3;
- uint64_t codeLimit64;
-} _packed;
-
-#ifndef LDID_NOFLAGT
-extern "C" uint32_t hash(uint8_t *k, uint32_t length, uint32_t initval);
-#endif
-
-struct Algorithm {
- size_t size_;
- uint8_t type_;
-
- Algorithm(size_t size, uint8_t type) :
- size_(size),
- type_(type)
- {
- }
-
- virtual const uint8_t *operator [](const ldid::Hash &hash) const = 0;
-
- virtual void operator ()(uint8_t *hash, const void *data, size_t size) const = 0;
- virtual void operator ()(ldid::Hash &hash, const void *data, size_t size) const = 0;
- virtual void operator ()(std::vector &hash, const void *data, size_t size) const = 0;
-};
-
-struct AlgorithmSHA1 :
- Algorithm
-{
- AlgorithmSHA1() :
- Algorithm(LDID_SHA1_DIGEST_LENGTH, CS_HASHTYPE_SHA160_160)
- {
- }
-
- virtual const uint8_t *operator [](const ldid::Hash &hash) const {
- return hash.sha1_;
- }
-
- void operator ()(uint8_t *hash, const void *data, size_t size) const {
- LDID_SHA1(static_cast(data), size, hash);
- }
-
- void operator ()(ldid::Hash &hash, const void *data, size_t size) const {
- return operator()(hash.sha1_, data, size);
- }
-
- void operator ()(std::vector &hash, const void *data, size_t size) const {
- hash.resize(LDID_SHA1_DIGEST_LENGTH);
- return operator ()(reinterpret_cast(hash.data()), data, size);
- }
-};
-
-struct AlgorithmSHA256 :
- Algorithm
-{
- AlgorithmSHA256() :
- Algorithm(LDID_SHA256_DIGEST_LENGTH, CS_HASHTYPE_SHA256_256)
- {
- }
-
- virtual const uint8_t *operator [](const ldid::Hash &hash) const {
- return hash.sha256_;
- }
-
- void operator ()(uint8_t *hash, const void *data, size_t size) const {
- LDID_SHA256(static_cast(data), size, hash);
- }
-
- void operator ()(ldid::Hash &hash, const void *data, size_t size) const {
- return operator()(hash.sha256_, data, size);
- }
-
- void operator ()(std::vector &hash, const void *data, size_t size) const {
- hash.resize(LDID_SHA256_DIGEST_LENGTH);
- return operator ()(reinterpret_cast(hash.data()), data, size);
- }
-};
-
-static const std::vector &GetAlgorithms() {
- static AlgorithmSHA1 sha1;
- static AlgorithmSHA256 sha256;
-
- static Algorithm *array[] = {
- &sha1,
- &sha256,
- };
-
- static std::vector algorithms(array, array + sizeof(array) / sizeof(array[0]));
- return algorithms;
-}
-
-struct CodesignAllocation {
- FatMachHeader mach_header_;
- uint32_t offset_;
- uint32_t size_;
- uint32_t limit_;
- uint32_t alloc_;
- uint32_t align_;
-
- CodesignAllocation(FatMachHeader mach_header, size_t offset, size_t size, size_t limit, size_t alloc, size_t align) :
- mach_header_(mach_header),
- offset_(offset),
- size_(size),
- limit_(limit),
- alloc_(alloc),
- align_(align)
- {
- }
-};
-
-#ifndef LDID_NOTOOLS
-class File {
- private:
- int file_;
-
- public:
- File() :
- file_(-1)
- {
- }
-
- ~File() {
- if (file_ != -1)
- _syscall(close(file_));
- }
-
- void open(const char *path, int flags) {
- _assert(file_ == -1);
- file_ = _syscall(::open(path, flags));
- }
-
- int file() const {
- return file_;
- }
-};
-
-class Map {
- private:
- File file_;
- void *data_;
- size_t size_;
-
- void clear() {
- if (data_ == NULL)
- return;
- _syscall(munmap(data_, size_));
- data_ = NULL;
- size_ = 0;
- }
-
- public:
- Map() :
- data_(NULL),
- size_(0)
- {
- }
-
- Map(const std::string &path, int oflag, int pflag, int mflag) :
- Map()
- {
- open(path, oflag, pflag, mflag);
- }
-
- Map(const std::string &path, bool edit) :
- Map()
- {
- open(path, edit);
- }
-
- ~Map() {
- clear();
- }
-
- bool empty() const {
- return data_ == NULL;
- }
-
- void open(const std::string &path, int oflag, int pflag, int mflag) {
- clear();
-
- file_.open(path.c_str(), oflag);
- int file(file_.file());
-
- struct stat stat;
- _syscall(fstat(file, &stat));
- size_ = stat.st_size;
-
- data_ = _syscall(mmap(NULL, size_, pflag, mflag, file, 0));
- }
-
- void open(const std::string &path, bool edit) {
- if (edit)
- open(path, O_RDWR, PROT_READ | PROT_WRITE, MAP_SHARED);
- else
- open(path, O_RDONLY, PROT_READ, MAP_PRIVATE);
- }
-
- void *data() const {
- return data_;
- }
-
- size_t size() const {
- return size_;
- }
-
- operator std::string() const {
- return std::string(static_cast(data_), size_);
- }
-};
-#endif
-
-namespace ldid {
-
-std::string Analyze(const void *data, size_t size) {
- std::string entitlements;
-
- FatHeader fat_header(const_cast(data), size);
- _foreach (mach_header, fat_header.GetMachHeaders())
- _foreach (load_command, mach_header.GetLoadCommands())
- if (mach_header.Swap(load_command->cmd) == LC_CODE_SIGNATURE) {
- auto signature(reinterpret_cast(load_command));
- auto offset(mach_header.Swap(signature->dataoff));
- auto pointer(reinterpret_cast(mach_header.GetBase()) + offset);
- auto super(reinterpret_cast(pointer));
-
- for (size_t index(0); index != Swap(super->count); ++index)
- if (Swap(super->index[index].type) == CSSLOT_ENTITLEMENTS) {
- auto begin(Swap(super->index[index].offset));
- auto blob(reinterpret_cast(pointer + begin));
- auto writ(Swap(blob->length) - sizeof(*blob));
-
- if (entitlements.empty())
- entitlements.assign(reinterpret_cast(blob + 1), writ);
- else
- _assert(entitlements.compare(0, entitlements.size(), reinterpret_cast(blob + 1), writ) == 0);
- }
- }
-
- return entitlements;
-}
-
-static void Allocate(const void *idata, size_t isize, std::streambuf &output, const Functor &allocate, const Functor &)> &save, const Functor &percent) {
- FatHeader source(const_cast(idata), isize);
-
- size_t offset(0);
- if (source.IsFat())
- offset += sizeof(fat_header) + sizeof(fat_arch) * source.Swap(source->nfat_arch);
-
- std::vector allocations;
- _foreach (mach_header, source.GetMachHeaders()) {
- struct linkedit_data_command *signature(NULL);
- struct symtab_command *symtab(NULL);
-
- _foreach (load_command, mach_header.GetLoadCommands()) {
- uint32_t cmd(mach_header.Swap(load_command->cmd));
- if (false);
- else if (cmd == LC_CODE_SIGNATURE)
- signature = reinterpret_cast(load_command);
- else if (cmd == LC_SYMTAB)
- symtab = reinterpret_cast(load_command);
- }
-
- size_t size;
- if (signature == NULL)
- size = mach_header.GetSize();
- else {
- size = mach_header.Swap(signature->dataoff);
- _assert(size <= mach_header.GetSize());
- }
-
- if (symtab != NULL) {
- auto end(mach_header.Swap(symtab->stroff) + mach_header.Swap(symtab->strsize));
- _assert(end <= size);
- _assert(end >= size - 0x10);
- size = end;
- }
-
- size_t alloc(allocate(mach_header, size));
-
- auto *fat_arch(mach_header.GetFatArch());
- uint32_t align;
-
- if (fat_arch != NULL)
- align = source.Swap(fat_arch->align);
- else switch (mach_header.GetCPUType()) {
- case CPU_TYPE_POWERPC:
- case CPU_TYPE_POWERPC64:
- case CPU_TYPE_X86:
- case CPU_TYPE_X86_64:
- align = 0xc;
- break;
- case CPU_TYPE_ARM:
- case CPU_TYPE_ARM64:
- align = 0xe;
- break;
- default:
- align = 0x0;
- break;
- }
-
- offset = Align(offset, 1 << align);
-
- uint32_t limit(size);
- if (alloc != 0)
- limit = Align(limit, 0x10);
-
- allocations.push_back(CodesignAllocation(mach_header, offset, size, limit, alloc, align));
- offset += size + alloc;
- offset = Align(offset, 0x10);
- }
-
- size_t position(0);
-
- if (source.IsFat()) {
- fat_header fat_header;
- fat_header.magic = Swap(FAT_MAGIC);
- fat_header.nfat_arch = Swap(uint32_t(allocations.size()));
- put(output, &fat_header, sizeof(fat_header));
- position += sizeof(fat_header);
-
- _foreach (allocation, allocations) {
- auto &mach_header(allocation.mach_header_);
-
- fat_arch fat_arch;
- fat_arch.cputype = Swap(mach_header->cputype);
- fat_arch.cpusubtype = Swap(mach_header->cpusubtype);
- fat_arch.offset = Swap(allocation.offset_);
- fat_arch.size = Swap(allocation.limit_ + allocation.alloc_);
- fat_arch.align = Swap(allocation.align_);
- put(output, &fat_arch, sizeof(fat_arch));
- position += sizeof(fat_arch);
- }
- }
-
- _foreach (allocation, allocations) {
- auto &mach_header(allocation.mach_header_);
-
- pad(output, allocation.offset_ - position);
- position = allocation.offset_;
-
- std::vector commands;
-
- _foreach (load_command, mach_header.GetLoadCommands()) {
- std::string copy(reinterpret_cast(load_command), load_command->cmdsize);
-
- switch (mach_header.Swap(load_command->cmd)) {
- case LC_CODE_SIGNATURE:
- continue;
- break;
-
- case LC_SEGMENT: {
- auto segment_command(reinterpret_cast(©[0]));
- if (strncmp(segment_command->segname, "__LINKEDIT", 16) != 0)
- break;
- size_t size(mach_header.Swap(allocation.limit_ + allocation.alloc_ - mach_header.Swap(segment_command->fileoff)));
- segment_command->filesize = size;
- segment_command->vmsize = Align(size, 1 << allocation.align_);
- } break;
-
- case LC_SEGMENT_64: {
- auto segment_command(reinterpret_cast(©[0]));
- if (strncmp(segment_command->segname, "__LINKEDIT", 16) != 0)
- break;
- size_t size(mach_header.Swap(allocation.limit_ + allocation.alloc_ - mach_header.Swap(segment_command->fileoff)));
- segment_command->filesize = size;
- segment_command->vmsize = Align(size, 1 << allocation.align_);
- } break;
- }
-
- commands.push_back(copy);
- }
-
- if (allocation.alloc_ != 0) {
- linkedit_data_command signature;
- signature.cmd = mach_header.Swap(LC_CODE_SIGNATURE);
- signature.cmdsize = mach_header.Swap(uint32_t(sizeof(signature)));
- signature.dataoff = mach_header.Swap(allocation.limit_);
- signature.datasize = mach_header.Swap(allocation.alloc_);
- commands.push_back(std::string(reinterpret_cast(&signature), sizeof(signature)));
- }
-
- size_t begin(position);
-
- uint32_t after(0);
- _foreach(command, commands)
- after += command.size();
-
- std::stringbuf altern;
-
- struct mach_header header(*mach_header);
- header.ncmds = mach_header.Swap(uint32_t(commands.size()));
- header.sizeofcmds = mach_header.Swap(after);
- put(output, &header, sizeof(header));
- put(altern, &header, sizeof(header));
- position += sizeof(header);
-
- if (mach_header.Bits64()) {
- auto pad(mach_header.Swap(uint32_t(0)));
- put(output, &pad, sizeof(pad));
- put(altern, &pad, sizeof(pad));
- position += sizeof(pad);
- }
-
- _foreach(command, commands) {
- put(output, command.data(), command.size());
- put(altern, command.data(), command.size());
- position += command.size();
- }
-
- uint32_t before(mach_header.Swap(mach_header->sizeofcmds));
- if (before > after) {
- pad(output, before - after);
- pad(altern, before - after);
- position += before - after;
- }
-
- auto top(reinterpret_cast(mach_header.GetBase()));
-
- std::string overlap(altern.str());
- overlap.append(top + overlap.size(), Align(overlap.size(), 0x1000) - overlap.size());
-
- put(output, top + (position - begin), allocation.size_ - (position - begin), percent);
- position = begin + allocation.size_;
-
- pad(output, allocation.limit_ - allocation.size_);
- position += allocation.limit_ - allocation.size_;
-
- size_t saved(save(mach_header, output, allocation.limit_, overlap, top, percent));
- if (allocation.alloc_ > saved)
- pad(output, allocation.alloc_ - saved);
- else
- _assert(allocation.alloc_ == saved);
- position += allocation.alloc_;
- }
-}
-
-}
-
-typedef std::map Blobs;
-
-static void insert(Blobs &blobs, uint32_t slot, const std::stringbuf &buffer) {
- auto value(buffer.str());
- std::swap(blobs[slot], value);
-}
-
-static const std::string &insert(Blobs &blobs, uint32_t slot, uint32_t magic, const std::stringbuf &buffer) {
- auto value(buffer.str());
- Blob blob;
- blob.magic = Swap(magic);
- blob.length = Swap(uint32_t(sizeof(blob) + value.size()));
- value.insert(0, reinterpret_cast(&blob), sizeof(blob));
- auto &save(blobs[slot]);
- std::swap(save, value);
- return save;
-}
-
-static size_t put(std::streambuf &output, uint32_t magic, const Blobs &blobs) {
- size_t total(0);
- _foreach (blob, blobs)
- total += blob.second.size();
-
- struct SuperBlob super;
- super.blob.magic = Swap(magic);
- super.blob.length = Swap(uint32_t(sizeof(SuperBlob) + blobs.size() * sizeof(BlobIndex) + total));
- super.count = Swap(uint32_t(blobs.size()));
- put(output, &super, sizeof(super));
-
- size_t offset(sizeof(SuperBlob) + sizeof(BlobIndex) * blobs.size());
-
- _foreach (blob, blobs) {
- BlobIndex index;
- index.type = Swap(blob.first);
- index.offset = Swap(uint32_t(offset));
- put(output, &index, sizeof(index));
- offset += blob.second.size();
- }
-
- _foreach (blob, blobs)
- put(output, blob.second.data(), blob.second.size());
-
- return offset;
-}
-
-#ifndef LDID_NOSMIME
-class Buffer {
- private:
- BIO *bio_;
-
- public:
- Buffer(BIO *bio) :
- bio_(bio)
- {
- _assert(bio_ != NULL);
- }
-
- Buffer() :
- bio_(BIO_new(BIO_s_mem()))
- {
- }
-
- Buffer(const char *data, size_t size) :
- Buffer(BIO_new_mem_buf(const_cast(data), size))
- {
- }
-
- Buffer(const std::string &data) :
- Buffer(data.data(), data.size())
- {
- }
-
- Buffer(CMS_ContentInfo *cms) :
- Buffer()
- {
- _assert(i2d_CMS_bio(bio_, cms) != 0);
- }
-
- ~Buffer() {
- BIO_free_all(bio_);
- }
-
- operator BIO *() const {
- return bio_;
- }
-
- explicit operator std::string() const {
- char *data;
- auto size(BIO_get_mem_data(bio_, &data));
- return std::string(data, size);
- }
-};
-
-class Stuff {
- private:
- PKCS12 *value_;
- EVP_PKEY *key_;
- X509 *cert_;
- STACK_OF(X509) *ca_;
-
- public:
- Stuff(BIO *bio) :
- value_(d2i_PKCS12_bio(bio, NULL)),
- ca_(NULL)
- {
- _assert(value_ != NULL);
- _assert(PKCS12_parse(value_, "", &key_, &cert_, &ca_) != 0);
- _assert(key_ != NULL);
- _assert(cert_ != NULL);
- }
-
- Stuff(const std::string &data) :
- Stuff(Buffer(data))
- {
- }
-
- ~Stuff() {
- sk_X509_pop_free(ca_, X509_free);
- X509_free(cert_);
- EVP_PKEY_free(key_);
- PKCS12_free(value_);
- }
-
- operator PKCS12 *() const {
- return value_;
- }
-
- operator EVP_PKEY *() const {
- return key_;
- }
-
- operator X509 *() const {
- return cert_;
- }
-
- operator STACK_OF(X509) *() const {
- return ca_;
- }
-};
-
-class Signature {
- private:
- CMS_ContentInfo *value_;
-
- public:
- Signature(const Stuff &stuff, const Buffer &data)
- {
- int flags = CMS_PARTIAL | CMS_DETACHED | CMS_NOSMIMECAP | CMS_BINARY;
-
- CMS_ContentInfo *stream = CMS_sign(NULL, NULL, stuff, NULL, flags);
-
- // iOS 12 requires both SHA1 and SHA256 signing digests.
- CMS_add1_signer(stream, stuff, stuff, EVP_sha256(), flags);
- CMS_add1_signer(stream, stuff, stuff, EVP_sha1(), flags);
-
- CMS_final(stream, data, NULL, flags);
-
- value_ = stream;
- _assert(value_ != NULL);
- }
-
- ~Signature() {
- CMS_ContentInfo_free(value_);
- }
-
- operator CMS_ContentInfo *() const {
- return value_;
- }
-};
-#endif
-
-class NullBuffer :
- public std::streambuf
-{
- public:
- virtual std::streamsize xsputn(const char_type *data, std::streamsize size) {
- return size;
- }
-
- virtual int_type overflow(int_type next) {
- return next;
- }
-};
-
-class Digest {
- public:
- uint8_t sha1_[LDID_SHA1_DIGEST_LENGTH];
-};
-
-class HashBuffer :
- public std::streambuf
-{
- private:
- ldid::Hash &hash_;
-
- LDID_SHA1_CTX sha1_;
- LDID_SHA256_CTX sha256_;
-
- public:
- HashBuffer(ldid::Hash &hash) :
- hash_(hash)
- {
- LDID_SHA1_Init(&sha1_);
- LDID_SHA256_Init(&sha256_);
- }
-
- ~HashBuffer() {
- LDID_SHA1_Final(reinterpret_cast(hash_.sha1_), &sha1_);
- LDID_SHA256_Final(reinterpret_cast(hash_.sha256_), &sha256_);
- }
-
- virtual std::streamsize xsputn(const char_type *data, std::streamsize size) {
- LDID_SHA1_Update(&sha1_, data, size);
- LDID_SHA256_Update(&sha256_, data, size);
- return size;
- }
-
- virtual int_type overflow(int_type next) {
- if (next == traits_type::eof())
- return sync();
- char value(next);
- xsputn(&value, 1);
- return next;
- }
-};
-
-class HashProxy :
- public HashBuffer
-{
- private:
- std::streambuf &buffer_;
-
- public:
- HashProxy(ldid::Hash &hash, std::streambuf &buffer) :
- HashBuffer(hash),
- buffer_(buffer)
- {
- }
-
- virtual std::streamsize xsputn(const char_type *data, std::streamsize size) {
- _assert(HashBuffer::xsputn(data, size) == size);
- return buffer_.sputn(data, size);
- }
-};
-
-#ifndef LDID_NOTOOLS
-static bool Starts(const std::string &lhs, const std::string &rhs) {
- return lhs.size() >= rhs.size() && lhs.compare(0, rhs.size(), rhs) == 0;
-}
-
-class Split {
- public:
- std::string dir;
- std::string base;
-
- Split(const std::string &path) {
- size_t slash(path.rfind('/'));
- if (slash == std::string::npos)
- base = path;
- else {
- dir = path.substr(0, slash + 1);
- base = path.substr(slash + 1);
- }
- }
-};
-
-static void mkdir_p(const std::string &path) {
- if (path.empty())
- return;
-#ifdef __WIN32__
- if (_syscall(mkdir(path.c_str()), EEXIST) == -EEXIST)
- return;
-#else
- if (_syscall(mkdir(path.c_str(), 0755), EEXIST) == -EEXIST)
- return;
-#endif
- auto slash(path.rfind('/', path.size() - 1));
- if (slash == std::string::npos)
- return;
- mkdir_p(path.substr(0, slash));
-}
-
-static std::string Temporary(std::filebuf &file, const Split &split) {
- std::string temp(split.dir + ".ldid." + split.base);
- mkdir_p(split.dir);
- _assert_(file.open(temp.c_str(), std::ios::out | std::ios::trunc | std::ios::binary) == &file, "open(): %s", temp.c_str());
- return temp;
-}
-
-static void Commit(const std::string &path, const std::string &temp) {
- struct stat info;
- if (_syscall(stat(path.c_str(), &info), ENOENT) == 0) {
-#ifndef __WIN32__
- _syscall(chown(temp.c_str(), info.st_uid, info.st_gid));
-#endif
- _syscall(chmod(temp.c_str(), info.st_mode));
- }
-
- _syscall(rename(temp.c_str(), path.c_str()));
-}
-#endif
-
-namespace ldid {
-
-Hash Sign(const void *idata, size_t isize, std::streambuf &output, const std::string &identifier, const std::string &entitlements, const std::string &requirement, const std::string &key, const Slots &slots, const Functor &percent) {
- Hash hash;
-
- std::string team;
-
-#ifndef LDID_NOSMIME
- if (!key.empty()) {
- Stuff stuff(key);
- auto name(X509_get_subject_name(stuff));
- _assert(name != NULL);
- auto index(X509_NAME_get_index_by_NID(name, NID_organizationalUnitName, -1));
- _assert(index >= 0);
- auto next(X509_NAME_get_index_by_NID(name, NID_organizationalUnitName, index));
- _assert(next == -1);
- auto entry(X509_NAME_get_entry(name, index));
- _assert(entry != NULL);
- auto asn(X509_NAME_ENTRY_get_data(entry));
- _assert(asn != NULL);
- team.assign(reinterpret_cast(ASN1_STRING_data(asn)), ASN1_STRING_length(asn));
- }
-#endif
-
- // XXX: this is just a "sufficiently large number"
- size_t certificate(0x3000);
-
- Allocate(idata, isize, output, fun([&](const MachHeader &mach_header, size_t size) -> size_t {
- size_t alloc(sizeof(struct SuperBlob));
-
- uint32_t normal((size + PageSize_ - 1) / PageSize_);
-
- uint32_t special(0);
-
- _foreach (slot, slots)
- special = std::max(special, slot.first);
-
- mach_header.ForSection(fun([&](const char *segment, const char *section, void *data, size_t size) {
- if (strcmp(segment, "__TEXT") == 0 && section != NULL && strcmp(section, "__info_plist") == 0)
- special = std::max(special, CSSLOT_INFOSLOT);
- }));
-
- special = std::max(special, CSSLOT_REQUIREMENTS);
- alloc += sizeof(struct BlobIndex);
- if (requirement.empty())
- alloc += 0xc;
- else
- alloc += requirement.size();
-
- if (!entitlements.empty()) {
- special = std::max(special, CSSLOT_ENTITLEMENTS);
- alloc += sizeof(struct BlobIndex);
- alloc += sizeof(struct Blob);
- alloc += entitlements.size();
- }
-
- size_t directory(0);
-
- directory += sizeof(struct BlobIndex);
- directory += sizeof(struct Blob);
- directory += sizeof(struct CodeDirectory);
- directory += identifier.size() + 1;
-
- if (!team.empty())
- directory += team.size() + 1;
-
- for (Algorithm *algorithm : GetAlgorithms())
- alloc = Align(alloc + directory + (special + normal) * algorithm->size_, 16);
-
- if (!key.empty()) {
- alloc += sizeof(struct BlobIndex);
- alloc += sizeof(struct Blob);
- alloc += certificate;
- }
-
- return alloc;
- }), fun([&](const MachHeader &mach_header, std::streambuf &output, size_t limit, const std::string &overlap, const char *top, const Functor &percent) -> size_t {
- Blobs blobs;
-
- if (true) {
- std::stringbuf data;
-
- if (requirement.empty()) {
- Blobs requirements;
- put(data, CSMAGIC_REQUIREMENTS, requirements);
- } else {
- put(data, requirement.data(), requirement.size());
- }
-
- insert(blobs, CSSLOT_REQUIREMENTS, data);
- }
-
- if (!entitlements.empty()) {
- std::stringbuf data;
- put(data, entitlements.data(), entitlements.size());
- insert(blobs, CSSLOT_ENTITLEMENTS, CSMAGIC_EMBEDDED_ENTITLEMENTS, data);
- }
-
- Slots posts(slots);
-
- mach_header.ForSection(fun([&](const char *segment, const char *section, void *data, size_t size) {
- if (strcmp(segment, "__TEXT") == 0 && section != NULL && strcmp(section, "__info_plist") == 0) {
- auto &slot(posts[CSSLOT_INFOSLOT]);
- for (Algorithm *algorithm : GetAlgorithms())
- (*algorithm)(slot, data, size);
- }
- }));
-
- unsigned total(0);
- for (Algorithm *pointer : GetAlgorithms()) {
- Algorithm &algorithm(*pointer);
-
- std::stringbuf data;
-
- uint32_t special(0);
- _foreach (blob, blobs)
- special = std::max(special, blob.first);
- _foreach (slot, posts)
- special = std::max(special, slot.first);
- uint32_t normal((limit + PageSize_ - 1) / PageSize_);
-
- CodeDirectory directory;
- directory.version = Swap(uint32_t(0x00020200));
- directory.flags = Swap(uint32_t(0));
- directory.nSpecialSlots = Swap(special);
- directory.codeLimit = Swap(uint32_t(limit));
- directory.nCodeSlots = Swap(normal);
- directory.hashSize = algorithm.size_;
- directory.hashType = algorithm.type_;
- directory.spare1 = 0x00;
- directory.pageSize = PageShift_;
- directory.spare2 = Swap(uint32_t(0));
- directory.scatterOffset = Swap(uint32_t(0));
- directory.spare3 = Swap(uint32_t(0));
- directory.codeLimit64 = Swap(uint64_t(0));
-
- uint32_t offset(sizeof(Blob) + sizeof(CodeDirectory));
-
- directory.identOffset = Swap(uint32_t(offset));
- offset += identifier.size() + 1;
-
- if (team.empty())
- directory.teamIDOffset = Swap(uint32_t(0));
- else {
- directory.teamIDOffset = Swap(uint32_t(offset));
- offset += team.size() + 1;
- }
-
- offset += special * algorithm.size_;
- directory.hashOffset = Swap(uint32_t(offset));
- offset += normal * algorithm.size_;
-
- put(data, &directory, sizeof(directory));
-
- put(data, identifier.c_str(), identifier.size() + 1);
- if (!team.empty())
- put(data, team.c_str(), team.size() + 1);
-
- std::vector storage((special + normal) * algorithm.size_);
- auto *hashes(&storage[special * algorithm.size_]);
-
- memset(storage.data(), 0, special * algorithm.size_);
-
- _foreach (blob, blobs) {
- auto local(reinterpret_cast(&blob.second[0]));
- algorithm(hashes - blob.first * algorithm.size_, local, Swap(local->length));
- }
-
- _foreach (slot, posts)
- memcpy(hashes - slot.first * algorithm.size_, algorithm[slot.second], algorithm.size_);
-
- percent(0);
- if (normal != 1)
- for (size_t i = 0; i != normal - 1; ++i) {
- algorithm(hashes + i * algorithm.size_, (PageSize_ * i < overlap.size() ? overlap.data() : top) + PageSize_ * i, PageSize_);
- percent(double(i) / normal);
- }
- if (normal != 0)
- algorithm(hashes + (normal - 1) * algorithm.size_, top + PageSize_ * (normal - 1), ((limit - 1) % PageSize_) + 1);
- percent(1);
-
- put(data, storage.data(), storage.size());
-
- const auto &save(insert(blobs, total == 0 ? CSSLOT_CODEDIRECTORY : CSSLOT_ALTERNATE + total - 1, CSMAGIC_CODEDIRECTORY, data));
- algorithm(hash, save.data(), save.size());
-
- ++total;
- }
-
-#ifndef LDID_NOSMIME
- if (!key.empty()) {
- std::stringbuf data;
- const std::string &sign(blobs[CSSLOT_CODEDIRECTORY]);
-
- Stuff stuff(key);
- Buffer bio(sign);
-
- Signature signature(stuff, sign);
- Buffer result(signature);
- std::string value(result);
- put(data, value.data(), value.size());
-
- const auto &save(insert(blobs, CSSLOT_SIGNATURESLOT, CSMAGIC_BLOBWRAPPER, data));
- _assert(save.size() <= certificate);
- }
-#endif
-
- return put(output, CSMAGIC_EMBEDDED_SIGNATURE, blobs);
- }), percent);
-
- return hash;
-}
-
-#ifndef LDID_NOTOOLS
-static void Unsign(void *idata, size_t isize, std::streambuf &output, const Functor &percent) {
- Allocate(idata, isize, output, fun([](const MachHeader &mach_header, size_t size) -> size_t {
- return 0;
- }), fun([](const MachHeader &mach_header, std::streambuf &output, size_t limit, const std::string &overlap, const char *top, const Functor &percent) -> size_t {
- return 0;
- }), percent);
-}
-
-std::string DiskFolder::Path(const std::string &path) const {
- return path_ + "/" + path;
-}
-
-DiskFolder::DiskFolder(const std::string &path) :
- path_(path)
-{
-}
-
-DiskFolder::~DiskFolder() {
- if (!std::uncaught_exception())
- for (const auto &commit : commit_)
- Commit(commit.first, commit.second);
-}
-
-#ifndef __WIN32__
-std::string readlink(const std::string &path) {
- for (size_t size(1024); ; size *= 2) {
- std::string data;
- data.resize(size);
-
- int writ(_syscall(::readlink(path.c_str(), &data[0], data.size())));
- if (size_t(writ) >= size)
- continue;
-
- data.resize(writ);
- return data;
- }
-}
-#endif
-
-void DiskFolder::Find(const std::string &root, const std::string &base, const Functor &code, const Functor &)> &link) const {
- std::string path(Path(root) + base);
-
- DIR *dir(opendir(path.c_str()));
- _assert(dir != NULL);
- _scope({ _syscall(closedir(dir)); });
-
- while (auto child = readdir(dir)) {
- std::string name(child->d_name);
- if (name == "." || name == "..")
- continue;
- if (Starts(name, ".ldid."))
- continue;
-
- bool directory;
-
-#ifdef __WIN32__
- struct stat info;
- _syscall(stat((path + name).c_str(), &info));
- if (false);
- else if (S_ISDIR(info.st_mode))
- directory = true;
- else if (S_ISREG(info.st_mode))
- directory = false;
- else
- _assert_(false, "st_mode=%x", info.st_mode);
-#else
- switch (child->d_type) {
- case DT_DIR:
- directory = true;
- break;
- case DT_REG:
- directory = false;
- break;
- case DT_LNK:
- link(base + name, fun([&]() { return readlink(path + name); }));
- continue;
- default:
- _assert_(false, "d_type=%u", child->d_type);
- }
-#endif
-
- if (directory)
- Find(root, base + name + "/", code, link);
- else
- code(base + name);
- }
-}
-
-void DiskFolder::Save(const std::string &path, bool edit, const void *flag, const Functor &code) {
- if (!edit) {
- // XXX: use nullbuf
- std::stringbuf save;
- code(save);
- } else {
- std::filebuf save;
- auto from(Path(path));
- commit_[from] = Temporary(save, from);
- code(save);
- }
-}
-
-bool DiskFolder::Look(const std::string &path) const {
- return _syscall(access(Path(path).c_str(), R_OK), ENOENT) == 0;
-}
-
-void DiskFolder::Open(const std::string &path, const Functor &code) const {
- std::filebuf data;
- auto result(data.open(Path(path).c_str(), std::ios::binary | std::ios::in));
- _assert_(result == &data, "DiskFolder::Open(%s)", path.c_str());
-
- auto length(data.pubseekoff(0, std::ios::end, std::ios::in));
- data.pubseekpos(0, std::ios::in);
- code(data, length, NULL);
-}
-
-void DiskFolder::Find(const std::string &path, const Functor &code, const Functor &)> &link) const {
- Find(path, "", code, link);
-}
-#endif
-
-SubFolder::SubFolder(Folder &parent, const std::string &path) :
- parent_(parent),
- path_(path)
-{
-}
-
-void SubFolder::Save(const std::string &path, bool edit, const void *flag, const Functor &code) {
- return parent_.Save(path_ + path, edit, flag, code);
-}
-
-bool SubFolder::Look(const std::string &path) const {
- return parent_.Look(path_ + path);
-}
-
-void SubFolder::Open(const std::string &path, const Functor &code) const {
- return parent_.Open(path_ + path, code);
-}
-
-void SubFolder::Find(const std::string &path, const Functor &code, const Functor &)> &link) const {
- return parent_.Find(path_ + path, code, link);
-}
-
-std::string UnionFolder::Map(const std::string &path) const {
- auto remap(remaps_.find(path));
- if (remap == remaps_.end())
- return path;
- return remap->second;
-}
-
-void UnionFolder::Map(const std::string &path, const Functor &code, const std::string &file, const Functor &)> &save) const {
- if (file.size() >= path.size() && file.substr(0, path.size()) == path)
- code(file.substr(path.size()));
-}
-
-UnionFolder::UnionFolder(Folder &parent) :
- parent_(parent)
-{
-}
-
-void UnionFolder::Save(const std::string &path, bool edit, const void *flag, const Functor &code) {
- return parent_.Save(Map(path), edit, flag, code);
-}
-
-bool UnionFolder::Look(const std::string &path) const {
- auto file(resets_.find(path));
- if (file != resets_.end())
- return true;
- return parent_.Look(Map(path));
-}
-
-void UnionFolder::Open(const std::string &path, const Functor &code) const {
- auto file(resets_.find(path));
- if (file == resets_.end())
- return parent_.Open(Map(path), code);
- auto &entry(file->second);
-
- auto &data(*entry.data_);
- auto length(data.pubseekoff(0, std::ios::end, std::ios::in));
- data.pubseekpos(0, std::ios::in);
- code(data, length, entry.flag_);
-}
-
-void UnionFolder::Find(const std::string &path, const Functor &code, const Functor &)> &link) const {
- for (auto &reset : resets_)
- Map(path, code, reset.first, fun([&](const Functor &code) {
- auto &entry(reset.second);
- auto &data(*entry.data_);
- auto length(data.pubseekoff(0, std::ios::end, std::ios::in));
- data.pubseekpos(0, std::ios::in);
- code(data, length, entry.flag_);
- }));
-
- for (auto &remap : remaps_)
- Map(path, code, remap.first, fun([&](const Functor &code) {
- parent_.Open(remap.second, fun([&](std::streambuf &data, size_t length, const void *flag) {
- code(data, length, flag);
- }));
- }));
-
- parent_.Find(path, fun([&](const std::string &name) {
- if (deletes_.find(path + name) == deletes_.end())
- code(name);
- }), fun([&](const std::string &name, const Functor &read) {
- if (deletes_.find(path + name) == deletes_.end())
- link(name, read);
- }));
-}
-
-#ifndef LDID_NOTOOLS
-static void copy(std::streambuf &source, std::streambuf &target, size_t length, const ldid::Functor &percent) {
- percent(0);
- size_t total(0);
- for (;;) {
- char data[4096 * 4];
- size_t writ(source.sgetn(data, sizeof(data)));
- if (writ == 0)
- break;
- _assert(target.sputn(data, writ) == writ);
- total += writ;
- percent(double(total) / length);
- }
-}
-
-#ifndef LDID_NOPLIST
-static plist_t plist(const std::string &data) {
- plist_t plist(NULL);
- if (Starts(data, "bplist00"))
- plist_from_bin(data.data(), data.size(), &plist);
- else
- plist_from_xml(data.data(), data.size(), &plist);
- _assert(plist != NULL);
- return plist;
-}
-
-static void plist_d(std::streambuf &buffer, size_t length, const Functor &code) {
- std::stringbuf data;
- copy(buffer, data, length, ldid::fun(dummy));
- auto node(plist(data.str()));
- _scope({ plist_free(node); });
- _assert(plist_get_node_type(node) == PLIST_DICT);
- code(node);
-}
-
-static std::string plist_s(plist_t node) {
- _assert(node != NULL);
- _assert(plist_get_node_type(node) == PLIST_STRING);
- char *data;
- plist_get_string_val(node, &data);
- _scope({ free(data); });
- return data;
-}
-#endif
-
-enum Mode {
- NoMode,
- OptionalMode,
- OmitMode,
- NestedMode,
- TopMode,
-};
-
-class Expression {
- private:
- regex_t regex_;
- std::vector matches_;
-
- public:
- Expression(const std::string &code) {
- _assert_(regcomp(®ex_, code.c_str(), REG_EXTENDED) == 0, "regcomp()");
- matches_.resize(regex_.re_nsub + 1);
- }
-
- ~Expression() {
- regfree(®ex_);
- }
-
- bool operator ()(const std::string &data) {
- regmatch_t matches[matches_.size()];
- auto value(regexec(®ex_, data.c_str(), matches_.size(), matches, 0));
- if (value == REG_NOMATCH)
- return false;
- _assert_(value == 0, "regexec()");
- for (size_t i(0); i != matches_.size(); ++i)
- matches_[i].assign(data.data() + matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so);
- return true;
- }
-
- const std::string &operator [](size_t index) const {
- return matches_[index];
- }
-};
-
-struct Rule {
- unsigned weight_;
- Mode mode_;
- std::string code_;
-
- mutable std::auto_ptr regex_;
-
- Rule(unsigned weight, Mode mode, const std::string &code) :
- weight_(weight),
- mode_(mode),
- code_(code)
- {
- }
-
- Rule(const Rule &rhs) :
- weight_(rhs.weight_),
- mode_(rhs.mode_),
- code_(rhs.code_)
- {
- }
-
- void Compile() const {
- regex_.reset(new Expression(code_));
- }
-
- bool operator ()(const std::string &data) const {
- _assert(regex_.get() != NULL);
- return (*regex_)(data);
- }
-
- bool operator <(const Rule &rhs) const {
- if (weight_ > rhs.weight_)
- return true;
- if (weight_ < rhs.weight_)
- return false;
- return mode_ > rhs.mode_;
- }
-};
-
-struct RuleCode {
- bool operator ()(const Rule *lhs, const Rule *rhs) const {
- return lhs->code_ < rhs->code_;
- }
-};
-
-#ifndef LDID_NOPLIST
-static Hash Sign(const uint8_t *prefix, size_t size, std::streambuf &buffer, Hash &hash, std::streambuf &save, const std::string &identifier, const std::string &entitlements, const std::string &requirement, const std::string &key, const Slots &slots, size_t length, const Functor &percent) {
- // XXX: this is a miserable fail
- std::stringbuf temp;
- put(temp, prefix, size);
- copy(buffer, temp, length - size, percent);
- // XXX: this is a stupid hack
- pad(temp, 0x10 - (length & 0xf));
- auto data(temp.str());
-
- HashProxy proxy(hash, save);
- return Sign(data.data(), data.size(), proxy, identifier, entitlements, requirement, key, slots, percent);
-}
-
-Bundle Sign(const std::string &root, Folder &folder, const std::string &key, std::map &remote, const std::string &requirement, const Functor &alter, const Functor &progress, const Functor &percent) {
- std::string executable;
- std::string identifier;
-
- bool mac(false);
-
- std::string info("Info.plist");
- if (!folder.Look(info) && folder.Look("Resources/" + info)) {
- mac = true;
- info = "Resources/" + info;
- }
-
- folder.Open(info, fun([&](std::streambuf &buffer, size_t length, const void *flag) {
- plist_d(buffer, length, fun([&](plist_t node) {
- executable = plist_s(plist_dict_get_item(node, "CFBundleExecutable"));
- identifier = plist_s(plist_dict_get_item(node, "CFBundleIdentifier"));
- }));
- }));
-
- if (!mac && folder.Look("MacOS/" + executable)) {
- executable = "MacOS/" + executable;
- mac = true;
- }
-
- std::string entitlements;
- folder.Open(executable, fun([&](std::streambuf &buffer, size_t length, const void *flag) {
- // XXX: this is a miserable fail
- std::stringbuf temp;
- copy(buffer, temp, length, percent);
- // XXX: this is a stupid hack
- pad(temp, 0x10 - (length & 0xf));
- auto data(temp.str());
- entitlements = alter(root, Analyze(data.data(), data.size()));
- }));
-
- static const std::string directory("_CodeSignature/");
- static const std::string signature(directory + "CodeResources");
-
- std::map> versions;
-
- auto &rules1(versions[""]);
- auto &rules2(versions["2"]);
-
- const std::string resources(mac ? "Resources/" : "");
-
- if (true) {
- rules1.insert(Rule{1, NoMode, "^" + resources});
- if (!mac) rules1.insert(Rule{10000, OmitMode, "^(Frameworks/[^/]+\\.framework/|PlugIns/[^/]+\\.appex/|PlugIns/[^/]+\\.appex/Frameworks/[^/]+\\.framework/|())SC_Info/[^/]+\\.(sinf|supf|supp)$"});
- rules1.insert(Rule{1000, OptionalMode, "^" + resources + ".*\\.lproj/"});
- rules1.insert(Rule{1100, OmitMode, "^" + resources + ".*\\.lproj/locversion.plist$"});
- if (!mac) rules1.insert(Rule{10000, OmitMode, "^Watch/[^/]+\\.app/(Frameworks/[^/]+\\.framework/|PlugIns/[^/]+\\.appex/|PlugIns/[^/]+\\.appex/Frameworks/[^/]+\\.framework/)SC_Info/[^/]+\\.(sinf|supf|supp)$"});
- rules1.insert(Rule{1, NoMode, "^version.plist$"});
- }
-
- if (true) {
- rules2.insert(Rule{11, NoMode, ".*\\.dSYM($|/)"});
- rules2.insert(Rule{20, NoMode, "^" + resources});
- rules2.insert(Rule{2000, OmitMode, "^(.*/)?\\.DS_Store$"});
- if (!mac) rules2.insert(Rule{10000, OmitMode, "^(Frameworks/[^/]+\\.framework/|PlugIns/[^/]+\\.appex/|PlugIns/[^/]+\\.appex/Frameworks/[^/]+\\.framework/|())SC_Info/[^/]+\\.(sinf|supf|supp)$"});
- rules2.insert(Rule{10, NestedMode, "^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/"});
- rules2.insert(Rule{1, NoMode, "^.*"});
- rules2.insert(Rule{1000, OptionalMode, "^" + resources + ".*\\.lproj/"});
- rules2.insert(Rule{1100, OmitMode, "^" + resources + ".*\\.lproj/locversion.plist$"});
- rules2.insert(Rule{20, OmitMode, "^Info\\.plist$"});
- rules2.insert(Rule{20, OmitMode, "^PkgInfo$"});
- if (!mac) rules2.insert(Rule{10000, OmitMode, "^Watch/[^/]+\\.app/(Frameworks/[^/]+\\.framework/|PlugIns/[^/]+\\.appex/|PlugIns/[^/]+\\.appex/Frameworks/[^/]+\\.framework/)SC_Info/[^/]+\\.(sinf|supf|supp)$"});
- rules2.insert(Rule{10, NestedMode, "^[^/]+$"});
- rules2.insert(Rule{20, NoMode, "^embedded\\.provisionprofile$"});
- rules2.insert(Rule{20, NoMode, "^version\\.plist$"});
- }
-
- std::map local;
-
- std::string failure(mac ? "Contents/|Versions/[^/]*/Resources/" : "");
- Expression nested("^(Frameworks/[^/]*\\.framework|PlugIns/[^/]*\\.appex(()|/[^/]*.app))/(" + failure + ")Info\\.plist$");
- std::map bundles;
-
- folder.Find("", fun([&](const std::string &name) {
- if (!nested(name))
- return;
- auto bundle(root + Split(name).dir);
- bundle.resize(bundle.size() - resources.size());
- SubFolder subfolder(folder, bundle);
-
- bundles[nested[1]] = Sign(bundle, subfolder, key, local, "", Starts(name, "PlugIns/") ? alter :
- static_cast &>(fun([&](const std::string &, const std::string &entitlements) -> std::string { return entitlements; }))
- , progress, percent);
- }), fun([&](const std::string &name, const Functor &read) {
- }));
-
- std::set excludes;
-
- auto exclude([&](const std::string &name) {
- // BundleDiskRep::adjustResources -> builder.addExclusion
- if (name == executable || Starts(name, directory) || Starts(name, "_MASReceipt/") || name == "CodeResources")
- return true;
-
- for (const auto &bundle : bundles)
- if (Starts(name, bundle.first + "/")) {
- excludes.insert(name);
- return true;
- }
-
- return false;
- });
-
- std::map links;
-
- folder.Find("", fun([&](const std::string &name) {
- if (exclude(name))
- return;
-
- if (local.find(name) != local.end())
- return;
- auto &hash(local[name]);
-
- folder.Open(name, fun([&](std::streambuf &data, size_t length, const void *flag) {
- progress(root + name);
-
- union {
- struct {
- uint32_t magic;
- uint32_t count;
- };
-
- uint8_t bytes[8];
- } header;
-
- auto size(most(data, &header.bytes, sizeof(header.bytes)));
-
- if (name != "_WatchKitStub/WK" && size == sizeof(header.bytes))
- switch (Swap(header.magic)) {
- case FAT_MAGIC:
- // Java class file format
- if (Swap(header.count) >= 40)
- break;
- case FAT_CIGAM:
- case MH_MAGIC: case MH_MAGIC_64:
- case MH_CIGAM: case MH_CIGAM_64:
- folder.Save(name, true, flag, fun([&](std::streambuf &save) {
- Slots slots;
- Sign(header.bytes, size, data, hash, save, identifier, "", "", key, slots, length, percent);
- }));
- return;
- }
-
- folder.Save(name, false, flag, fun([&](std::streambuf &save) {
- HashProxy proxy(hash, save);
- put(proxy, header.bytes, size);
- copy(data, proxy, length - size, percent);
- }));
- }));
- }), fun([&](const std::string &name, const Functor &read) {
- if (exclude(name))
- return;
-
- links[name] = read();
- }));
-
- auto plist(plist_new_dict());
- _scope({ plist_free(plist); });
-
- for (const auto &version : versions) {
- auto files(plist_new_dict());
- plist_dict_set_item(plist, ("files" + version.first).c_str(), files);
-
- for (const auto &rule : version.second)
- rule.Compile();
-
- bool old(&version.second == &rules1);
-
- for (const auto &hash : local)
- for (const auto &rule : version.second)
- if (rule(hash.first)) {
- if (!old && mac && excludes.find(hash.first) != excludes.end());
- else if (old && rule.mode_ == NoMode)
- plist_dict_set_item(files, hash.first.c_str(), plist_new_data(reinterpret_cast(hash.second.sha1_), sizeof(hash.second.sha1_)));
- else if (rule.mode_ != OmitMode) {
- auto entry(plist_new_dict());
- plist_dict_set_item(entry, "hash", plist_new_data(reinterpret_cast(hash.second.sha1_), sizeof(hash.second.sha1_)));
- if (!old)
- plist_dict_set_item(entry, "hash2", plist_new_data(reinterpret_cast(hash.second.sha256_), sizeof(hash.second.sha256_)));
- if (rule.mode_ == OptionalMode)
- plist_dict_set_item(entry, "optional", plist_new_bool(true));
- plist_dict_set_item(files, hash.first.c_str(), entry);
- }
-
- break;
- }
-
- for (const auto &link : links)
- for (const auto &rule : version.second)
- if (rule(link.first)) {
- if (rule.mode_ != OmitMode) {
- auto entry(plist_new_dict());
- plist_dict_set_item(entry, "symlink", plist_new_string(link.second.c_str()));
- if (rule.mode_ == OptionalMode)
- plist_dict_set_item(entry, "optional", plist_new_bool(true));
- plist_dict_set_item(files, link.first.c_str(), entry);
- }
-
- break;
- }
-
- if (!old && mac)
- for (const auto &bundle : bundles) {
- auto entry(plist_new_dict());
- plist_dict_set_item(entry, "cdhash", plist_new_data(reinterpret_cast(bundle.second.hash.sha256_), sizeof(bundle.second.hash.sha256_)));
- plist_dict_set_item(entry, "requirement", plist_new_string("anchor apple generic"));
- plist_dict_set_item(files, bundle.first.c_str(), entry);
- }
- }
-
- for (const auto &version : versions) {
- auto rules(plist_new_dict());
- plist_dict_set_item(plist, ("rules" + version.first).c_str(), rules);
-
- std::multiset ordered;
- for (const auto &rule : version.second)
- ordered.insert(&rule);
-
- for (const auto &rule : ordered)
- if (rule->weight_ == 1 && rule->mode_ == NoMode)
- plist_dict_set_item(rules, rule->code_.c_str(), plist_new_bool(true));
- else {
- auto entry(plist_new_dict());
- plist_dict_set_item(rules, rule->code_.c_str(), entry);
-
- switch (rule->mode_) {
- case NoMode:
- break;
- case OmitMode:
- plist_dict_set_item(entry, "omit", plist_new_bool(true));
- break;
- case OptionalMode:
- plist_dict_set_item(entry, "optional", plist_new_bool(true));
- break;
- case NestedMode:
- plist_dict_set_item(entry, "nested", plist_new_bool(true));
- break;
- case TopMode:
- plist_dict_set_item(entry, "top", plist_new_bool(true));
- break;
- }
-
- if (rule->weight_ >= 10000)
- plist_dict_set_item(entry, "weight", plist_new_uint(rule->weight_));
- else if (rule->weight_ != 1)
- plist_dict_set_item(entry, "weight", plist_new_real(rule->weight_));
- }
- }
-
- folder.Save(signature, true, NULL, fun([&](std::streambuf &save) {
- HashProxy proxy(local[signature], save);
- char *xml(NULL);
- uint32_t size;
- plist_to_xml(plist, &xml, &size);
- _scope({ free(xml); });
- put(proxy, xml, size);
- }));
-
- Bundle bundle;
- bundle.path = executable;
-
- folder.Open(executable, fun([&](std::streambuf &buffer, size_t length, const void *flag) {
- progress(root + executable);
- folder.Save(executable, true, flag, fun([&](std::streambuf &save) {
- Slots slots;
- slots[1] = local.at(info);
- slots[3] = local.at(signature);
- bundle.hash = Sign(NULL, 0, buffer, local[executable], save, identifier, entitlements, requirement, key, slots, length, percent);
- }));
- }));
-
- for (const auto &entry : local)
- remote[root + entry.first] = entry.second;
-
- return bundle;
-}
-
-Bundle Sign(const std::string &root, Folder &folder, const std::string &key, const std::string &requirement, const Functor &alter, const Functor &progress, const Functor &percent) {
- std::map local;
- return Sign(root, folder, key, local, requirement, alter, progress, percent);
-}
-#endif
-
-#endif
-}
-
-#ifndef LDID_NOTOOLS
-int main(int argc, char *argv[]) {
-#ifndef LDID_NOSMIME
- OpenSSL_add_all_algorithms();
-#endif
-
- union {
- uint16_t word;
- uint8_t byte[2];
- } endian = {1};
-
- little_ = endian.byte[0];
-
- bool flag_r(false);
- bool flag_e(false);
- bool flag_q(false);
-
-#ifndef LDID_NOFLAGT
- bool flag_T(false);
-#endif
-
- bool flag_S(false);
- bool flag_s(false);
-
- bool flag_D(false);
-
- bool flag_A(false);
- bool flag_a(false);
-
- bool flag_u(false);
-
- uint32_t flag_CPUType(_not(uint32_t));
- uint32_t flag_CPUSubtype(_not(uint32_t));
-
- const char *flag_I(NULL);
-
-#ifndef LDID_NOFLAGT
- bool timeh(false);
- uint32_t timev(0);
-#endif
-
- Map entitlements;
- Map requirement;
- Map key;
- ldid::Slots slots;
-
- std::vector files;
-
- if (argc == 1) {
- fprintf(stderr, "usage: %s -S[entitlements.xml] \n", argv[0]);
- fprintf(stderr, " %s -e MobileSafari\n", argv[0]);
- fprintf(stderr, " %s -S cat\n", argv[0]);
- fprintf(stderr, " %s -Stfp.xml gdb\n", argv[0]);
- exit(0);
- }
-
- for (int argi(1); argi != argc; ++argi)
- if (argv[argi][0] != '-')
- files.push_back(argv[argi]);
- else switch (argv[argi][1]) {
- case 'r':
- _assert(!flag_s);
- _assert(!flag_S);
- flag_r = true;
- break;
-
- case 'e': flag_e = true; break;
-
- case 'E': {
- const char *string = argv[argi] + 2;
- const char *colon = strchr(string, ':');
- _assert(colon != NULL);
- Map file(colon + 1, O_RDONLY, PROT_READ, MAP_PRIVATE);
- char *arge;
- unsigned number(strtoul(string, &arge, 0));
- _assert(arge == colon);
- auto &slot(slots[number]);
- for (Algorithm *algorithm : GetAlgorithms())
- (*algorithm)(slot, file.data(), file.size());
- } break;
-
- case 'q': flag_q = true; break;
-
- case 'Q': {
- const char *xml = argv[argi] + 2;
- requirement.open(xml, O_RDONLY, PROT_READ, MAP_PRIVATE);
- } break;
-
- case 'D': flag_D = true; break;
-
- case 'a': flag_a = true; break;
-
- case 'A':
- _assert(!flag_A);
- flag_A = true;
- if (argv[argi][2] != '\0') {
- const char *cpu = argv[argi] + 2;
- const char *colon = strchr(cpu, ':');
- _assert(colon != NULL);
- char *arge;
- flag_CPUType = strtoul(cpu, &arge, 0);
- _assert(arge == colon);
- flag_CPUSubtype = strtoul(colon + 1, &arge, 0);
- _assert(arge == argv[argi] + strlen(argv[argi]));
- }
- break;
-
- case 's':
- _assert(!flag_r);
- _assert(!flag_S);
- flag_s = true;
- break;
-
- case 'S':
- _assert(!flag_r);
- _assert(!flag_s);
- flag_S = true;
- if (argv[argi][2] != '\0') {
- const char *xml = argv[argi] + 2;
- entitlements.open(xml, O_RDONLY, PROT_READ, MAP_PRIVATE);
- }
- break;
-
- case 'K':
- if (argv[argi][2] != '\0')
- key.open(argv[argi] + 2, O_RDONLY, PROT_READ, MAP_PRIVATE);
- break;
-
-#ifndef LDID_NOFLAGT
- case 'T': {
- flag_T = true;
- if (argv[argi][2] == '-')
- timeh = true;
- else {
- char *arge;
- timev = strtoul(argv[argi] + 2, &arge, 0);
- _assert(arge == argv[argi] + strlen(argv[argi]));
- }
- } break;
-#endif
-
- case 'u': {
- flag_u = true;
- } break;
-
- case 'I': {
- flag_I = argv[argi] + 2;
- } break;
-
- default:
- goto usage;
- break;
- }
-
- _assert(flag_S || key.empty());
- _assert(flag_S || flag_I == NULL);
-
- if (files.empty()) usage: {
- exit(0);
- }
-
- size_t filei(0), filee(0);
- _foreach (file, files) try {
- std::string path(file);
-
- struct stat info;
- _syscall(stat(path.c_str(), &info));
-
- if (S_ISDIR(info.st_mode)) {
-#ifndef LDID_NOPLIST
- _assert(!flag_r);
- ldid::DiskFolder folder(path);
- path += "/" + Sign("", folder, key, requirement, ldid::fun([&](const std::string &, const std::string &) -> std::string { return entitlements; })
- , ldid::fun([&](const std::string &) {}), ldid::fun(dummy)
- ).path;
-#else
- _assert(false);
-#endif
- } else if (flag_S || flag_r) {
- Map input(path, O_RDONLY, PROT_READ, MAP_PRIVATE);
-
- std::filebuf output;
- Split split(path);
- auto temp(Temporary(output, split));
-
- if (flag_r)
- ldid::Unsign(input.data(), input.size(), output, ldid::fun(dummy));
- else {
- std::string identifier(flag_I ?: split.base.c_str());
- ldid::Sign(input.data(), input.size(), output, identifier, entitlements, requirement, key, slots, ldid::fun(dummy));
- }
-
- Commit(path, temp);
- }
-
- bool modify(false);
-#ifndef LDID_NOFLAGT
- if (flag_T)
- modify = true;
-#endif
- if (flag_s)
- modify = true;
-
- Map mapping(path, modify);
- FatHeader fat_header(mapping.data(), mapping.size());
-
- _foreach (mach_header, fat_header.GetMachHeaders()) {
- struct linkedit_data_command *signature(NULL);
- struct encryption_info_command *encryption(NULL);
-
- if (flag_A) {
- if (mach_header.GetCPUType() != flag_CPUType)
- continue;
- if (mach_header.GetCPUSubtype() != flag_CPUSubtype)
- continue;
- }
-
- if (flag_a)
- printf("cpu=0x%x:0x%x\n", mach_header.GetCPUType(), mach_header.GetCPUSubtype());
-
- _foreach (load_command, mach_header.GetLoadCommands()) {
- uint32_t cmd(mach_header.Swap(load_command->cmd));
-
- if (false);
- else if (cmd == LC_CODE_SIGNATURE)
- signature = reinterpret_cast(load_command);
- else if (cmd == LC_ENCRYPTION_INFO || cmd == LC_ENCRYPTION_INFO_64)
- encryption = reinterpret_cast(load_command);
- else if (cmd == LC_LOAD_DYLIB) {
- volatile struct dylib_command *dylib_command(reinterpret_cast(load_command));
- const char *name(reinterpret_cast(load_command) + mach_header.Swap(dylib_command->dylib.name));
-
- if (strcmp(name, "/System/Library/Frameworks/UIKit.framework/UIKit") == 0) {
- if (flag_u) {
- Version version;
- version.value = mach_header.Swap(dylib_command->dylib.current_version);
- printf("uikit=%u.%u.%u\n", version.major, version.minor, version.patch);
- }
- }
- }
-#ifndef LDID_NOFLAGT
- else if (cmd == LC_ID_DYLIB) {
- volatile struct dylib_command *dylib_command(reinterpret_cast(load_command));
-
- if (flag_T) {
- uint32_t timed;
-
- if (!timeh)
- timed = timev;
- else {
- dylib_command->dylib.timestamp = 0;
- timed = hash(reinterpret_cast(mach_header.GetBase()), mach_header.GetSize(), timev);
- }
-
- dylib_command->dylib.timestamp = mach_header.Swap(timed);
- }
- }
-#endif
- }
-
- if (flag_D) {
- _assert(encryption != NULL);
- encryption->cryptid = mach_header.Swap(0);
- }
-
- if (flag_e) {
- _assert(signature != NULL);
-
- uint32_t data = mach_header.Swap(signature->dataoff);
-
- uint8_t *top = reinterpret_cast(mach_header.GetBase());
- uint8_t *blob = top + data;
- struct SuperBlob *super = reinterpret_cast(blob);
-
- for (size_t index(0); index != Swap(super->count); ++index)
- if (Swap(super->index[index].type) == CSSLOT_ENTITLEMENTS) {
- uint32_t begin = Swap(super->index[index].offset);
- struct Blob *entitlements = reinterpret_cast(blob + begin);
- fwrite(entitlements + 1, 1, Swap(entitlements->length) - sizeof(*entitlements), stdout);
- }
- }
-
- if (flag_q) {
- _assert(signature != NULL);
-
- uint32_t data = mach_header.Swap(signature->dataoff);
-
- uint8_t *top = reinterpret_cast(mach_header.GetBase());
- uint8_t *blob = top + data;
- struct SuperBlob *super = reinterpret_cast(blob);
-
- for (size_t index(0); index != Swap(super->count); ++index)
- if (Swap(super->index[index].type) == CSSLOT_REQUIREMENTS) {
- uint32_t begin = Swap(super->index[index].offset);
- struct Blob *requirement = reinterpret_cast(blob + begin);
- fwrite(requirement, 1, Swap(requirement->length), stdout);
- }
- }
-
- if (flag_s) {
- _assert(signature != NULL);
-
- uint32_t data = mach_header.Swap(signature->dataoff);
-
- uint8_t *top = reinterpret_cast(mach_header.GetBase());
- uint8_t *blob = top + data;
- struct SuperBlob *super = reinterpret_cast(blob);
-
- for (size_t index(0); index != Swap(super->count); ++index)
- if (Swap(super->index[index].type) == CSSLOT_CODEDIRECTORY) {
- uint32_t begin = Swap(super->index[index].offset);
- struct CodeDirectory *directory = reinterpret_cast(blob + begin + sizeof(Blob));
-
- uint8_t (*hashes)[LDID_SHA1_DIGEST_LENGTH] = reinterpret_cast(blob + begin + Swap(directory->hashOffset));
- uint32_t pages = Swap(directory->nCodeSlots);
-
- if (pages != 1)
- for (size_t i = 0; i != pages - 1; ++i)
- LDID_SHA1(top + PageSize_ * i, PageSize_, hashes[i]);
- if (pages != 0)
- LDID_SHA1(top + PageSize_ * (pages - 1), ((data - 1) % PageSize_) + 1, hashes[pages - 1]);
- }
- }
- }
-
- ++filei;
- } catch (const char *) {
- ++filee;
- ++filei;
- }
-
- return filee;
-}
-#endif
diff --git a/ldid2/ldid.hpp b/ldid2/ldid.hpp
deleted file mode 100644
index 58bbc09..0000000
--- a/ldid2/ldid.hpp
+++ /dev/null
@@ -1,159 +0,0 @@
-#ifndef LDID_HPP
-#define LDID_HPP
-
-#include
-#include