Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch out any instances of printf in upstream #663

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions secp256k1-sys/depend/secp256k1/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ static const rustsecp256k1_v0_9_0_callback default_error_callback = {
#endif

static SECP256K1_INLINE void *checked_malloc(const rustsecp256k1_v0_9_0_callback* cb, size_t size) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe delete it completely to ensure it's not called by accident?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I would need to delete all the functions that call it, and so on, which is much more invasive.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sucks. Also I wonder how does it interact with the system library. Will anything break if it has different code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It's not an exposed function, it's only used internally.

void *ret = malloc(size);
if (ret == NULL) {
rustsecp256k1_v0_9_0_callback_call(cb, "Out of memory");
}
return ret;
(void) cb;
(void) size;
return NULL;
}

#if defined(__BIGGEST_ALIGNMENT__)
Expand Down
10 changes: 10 additions & 0 deletions secp256k1-sys/depend/util.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
148,152c148,150
< void *ret = malloc(size);
< if (ret == NULL) {
< secp256k1_callback_call(cb, "Out of memory");
< }
< return ret;
---
> (void) cb;
> (void) size;
> return NULL;
1 change: 1 addition & 0 deletions secp256k1-sys/vendor-libsecp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ echo "$SOURCE_REV" >> ./secp256k1-HEAD-revision.txt
patch "$DIR/include/secp256k1.h" "./secp256k1.h.patch"
patch "$DIR/src/secp256k1.c" "./secp256k1.c.patch"
patch "$DIR/src/scratch_impl.h" "./scratch_impl.h.patch"
patch "$DIR/src/util.h" "./util.h.patch"

# Fix a linking error while cross-compiling to windowns with mingw
patch "$DIR/contrib/lax_der_parsing.c" "./lax_der_parsing.c.patch"
Expand Down
Loading