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

Compile error #3

Closed
cswea3 opened this issue Aug 19, 2016 · 5 comments
Closed

Compile error #3

cswea3 opened this issue Aug 19, 2016 · 5 comments
Labels

Comments

@cswea3
Copy link

cswea3 commented Aug 19, 2016

Error given:

base64.cpp:39:44: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
   BIO *bio = BIO_new_mem_buf(b64message, -1)
g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.

I fixed it on my copy but have never sent in a bug fix before so I am not sure how to.

@shanet
Copy link
Owner

shanet commented Aug 19, 2016

Thanks for the report. I don't have that issue with GCC 6.1.1. Could you post the output of openssl version here please?

You can generate a quick diff of what you've changed by running git diff as well. Posting the output of that here will allow me to merge your fixes in without having to go through a whole pull request process (unless you want to do that, of course!).

@shanet shanet added the bug label Aug 19, 2016
@cswea3
Copy link
Author

cswea3 commented Aug 19, 2016

In basecode64.cpp in your base64Decode function parameters I changed it from const char *b64message to just char *b64message.

In my version of openssl bio.h and according to their wiki at https://wiki.openssl.org/index.php/Manual:BIO_s_mem%283%29

BIO_new_mem_buf takes a void* as it's first argument not const void*

openssl version

OpenSSL 1.0.1e-fips 11 Feb 2013

git diff
diff --git a/base64.cpp b/base64.cpp
index 011726e..b884374 100644
--- a/base64.cpp
+++ b/base64.cpp
@@ -27,7 +27,7 @@ char* base64Encode(const unsigned char *message, const size_t length) {
   return b64text;
 }

-int base64Decode(const char *b64message, const size_t length, unsigned char **buffer) {
+int base64Decode(char *b64message, const size_t length, unsigned char **buffer) {
   int decodedLength = calcDecodeLength(b64message, length);
   *buffer = (unsigned char*)malloc(decodedLength + 1);

@cswea3
Copy link
Author

cswea3 commented Aug 19, 2016

It seems to be a problem with BIO_new_mem_buf as it should take a const void*
Reference https://mta.openssl.org/pipermail/openssl-dev/2015-November/003299.html

@shanet
Copy link
Owner

shanet commented Aug 20, 2016

Yup, thanks for digging that up. And the current head uses a const pointer (https://github.com/openssl/openssl/blob/5e93e5fc377ebc8bc30ffac1fa20a04cb25459eb/crypto/bio/bss_mem.c#L73) so I think I'm going to leave this as-is. If possible, you should upgrade your version of OpenSSL. 1.0.1e is quite old at this point and, most notably, is vulnerable to the Heartbleed bug.

@shanet shanet closed this as completed Aug 20, 2016
@shanet
Copy link
Owner

shanet commented Aug 20, 2016

I'll add a note to the README though recommending an up-to-date version of OpenSSL to avoid problems like this that others may have run into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants