Skip to content

Commit d7c54a8

Browse files
authored
chore: update lief (#23)
This change updates lief to lief-project/LIEF@b183666. This contains lief-project/LIEF#780, which is a requirement for #8. Signed-off-by: Darshan Sen <[email protected]>
1 parent ab1211d commit d7c54a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+465
-179
lines changed

DEPENDENCIES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
lief https://github.com/lief-project/LIEF/ 9cf3b56cf004407c56695a61688ecc8ac511ef0e
1+
lief https://github.com/lief-project/LIEF/ b183666a082d19ffc91ed0763f49e1d4f3814a59
22
vendorpull https://github.com/jviotti/vendorpull 8445d0d0b15d308906ee395cc3313cba461865c4

vendor/lief/CMakeLists.txt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
cmake_minimum_required(VERSION 3.5)
22

3+
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
4+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
5+
cmake_policy(SET CMP0135 NEW)
6+
endif()
7+
38
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
49

510
# Modules
@@ -464,15 +469,6 @@ endif()
464469

465470
target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)
466471

467-
# Enable support for MD2 and MD4 for parsing the Authenticode sigs of older
468-
# executables. Also, some older signed executables use certs with the
469-
# SpcSpAgencyInfo Critical Extension, which mbed TLS doesn't support, so set
470-
# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION to have it skip this
471-
# extension.
472-
add_definitions(-DMBEDTLS_FS_IO -DMBEDTLS_PEM_PARSE_C -DMBEDTLS_BIGNUM_C
473-
-DMBEDTLS_X509_CRT_PARSE_C -DMBEDTLS_PEM_WRITE_C
474-
-DMBEDTLS_PKCS1_V15 -DMBEDTLS_PKCS1_V21)
475-
476472
# LIEF Sanitizer options
477473
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
478474
set(SANITIZER_FLAGS -fno-omit-frame-pointer -g -O1)

vendor/lief/api/c/MachO/Parser.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,27 @@ using namespace LIEF::MachO;
2525

2626
Macho_Binary_t** macho_parse(const char *file) {
2727
FatBinary* fat = Parser::parse(file).release();
28+
if (fat == nullptr) {
29+
return nullptr;
30+
}
31+
32+
size_t nb_bin = fat->size();
2833

2934
auto** c_macho_binaries = static_cast<Macho_Binary_t**>(
3035
malloc((fat->size() + 1) * sizeof(Macho_Binary_t**)));
3136

32-
for (size_t i = 0; i < fat->size(); ++i) {
37+
for (size_t i = 0; i < nb_bin; ++i) {
3338
Binary* binary = fat->at(i);
3439
if (binary != nullptr) {
3540
c_macho_binaries[i] = static_cast<Macho_Binary_t*>(malloc(sizeof(Macho_Binary_t)));
3641
init_c_binary(c_macho_binaries[i], binary);
3742
}
3843
}
3944

40-
c_macho_binaries[fat->size()] = nullptr;
45+
fat->release_all_binaries();
46+
47+
c_macho_binaries[nb_bin] = nullptr;
48+
delete fat;
4149

4250
return c_macho_binaries;
4351
}

vendor/lief/api/python/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
cmake_minimum_required(VERSION 3.1)
2+
3+
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
4+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
5+
cmake_policy(SET CMP0135 NEW)
6+
endif()
7+
28
include(ExternalProject)
39
include(CheckCXXCompilerFlag)
410
include(CheckCCompilerFlag)

vendor/lief/api/python/DEX/objects/pyType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void create<Type>(py::module& m) {
7373

7474
case Type::TYPES::CLASS:
7575
{
76-
return py::cast(type.cls());
76+
return py::cast(type.cls(), py::return_value_policy::reference);
7777
}
7878

7979
case Type::TYPES::PRIMITIVE:

vendor/lief/api/python/ELF/objects/pyBinary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void create<Binary>(py::module& m) {
500500
"permutation"_a)
501501

502502
.def("write",
503-
&Binary::write,
503+
static_cast<void (Binary::*)(const std::string&)>(&Binary::write),
504504
"Rebuild the binary and write it in a file",
505505
"output"_a,
506506
py::return_value_policy::reference_internal)

vendor/lief/api/python/ELF/objects/pyBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void create<Builder>(py::module& m) {
6868
py::return_value_policy::reference_internal)
6969

7070
.def("write",
71-
&Builder::write,
71+
static_cast<void (Builder::*)(const std::string&) const>(&Builder::write),
7272
"Write the build result into the ``output`` file",
7373
"output"_a)
7474

vendor/lief/api/python/MachO/objects/pyBinary.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void create<Binary>(py::module& m) {
424424
"address"_a)
425425

426426
.def("write",
427-
&Binary::write,
427+
static_cast<void (Binary::*)(const std::string&)>(&Binary::write),
428428
"Rebuild the binary and write and write its content if the file given in parameter",
429429
"output"_a,
430430
py::return_value_policy::reference_internal)
@@ -584,7 +584,9 @@ void create<Binary>(py::module& m) {
584584
py::return_value_policy::reference_internal)
585585

586586
.def("shift",
587-
&Binary::shift,
587+
[] (Binary& self, size_t width) {
588+
return error_or(&Binary::shift, self, width);
589+
},
588590
R"delim(
589591
Shift the content located right after the Load commands table.
590592
This operation can be used to add a new command

vendor/lief/api/python/PE/objects/pyBinary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void create<Binary>(py::module& m) {
405405
"Remove all imported libraries")
406406

407407
.def("write",
408-
&Binary::write,
408+
static_cast<void (Binary::*)(const std::string&)>(&Binary::write),
409409
"Build the binary and write the result to the given ``output`` file",
410410
"output_path"_a)
411411

vendor/lief/api/python/PE/objects/pyBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void create<Builder>(py::module& m) {
9494
py::return_value_policy::reference)
9595

9696
.def("write",
97-
&Builder::write,
97+
static_cast<void (Builder::*)(const std::string&) const>(&Builder::write),
9898
"Write the build result into the ``output`` file",
9999
"output"_a)
100100

0 commit comments

Comments
 (0)