dhamaniasad / py-bcrypt

Automatically exported from code.google.com/p/py-bcrypt
Other
2 stars 0 forks source link

Build failure on mingw32 with solution, updated for 0.3 #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. ~/pydistutils.cfg has compiler = mingw32 in [build]
2. pip install py-bcrypt
3. python test\test.py

What is the expected output? What do you see instead?
Clean install.
Compile errors for u_int8_t. After fixing those segfaults calling hashpw.

What version of the product are you using? On what operating system?
py-bcrypt 0.2 on Windows 7. MinGW is gcc 4.6.2.

Please provide any additional information below.
This supersedes issue 9 as the patches are different.

The three attached patches address a number of problems.
1. u_int8_t, etc. are not standard C.
2. strdup on Windows is deprecated since VS2005, using _strdup instead.
3. Explicit cast added calling encode_salt.
4. memset to zero password and salt copies (duplicate of other patches, more 
portable than bzero).

This is only tested on mingw32 but the ifdefs should be good for other 
platforms.

Original issue reported on code.google.com by pet...@gmail.com on 20 May 2013 at 10:00

Attachments:

GoogleCodeExporter commented 9 years ago
Correct patch file for bcrypt.c

Original comment by pet...@gmail.com on 20 May 2013 at 11:27

Attachments:

GoogleCodeExporter commented 9 years ago
Built okay on CentOS 6.3 with gcc 4.4.6.

Original comment by pet...@gmail.com on 20 May 2013 at 2:14

GoogleCodeExporter commented 9 years ago
There is a typo, I meant py-bcrypt 0.3 on Windows 7. MinGW is gcc 4.6.2.

Original comment by pet...@gmail.com on 20 May 2013 at 2:18

GoogleCodeExporter commented 9 years ago
Could you please try the current hg tip? It has a number of fixes for windows 
that seem roughly equivalent to these. Unfortunately, I don't have access to 
MSVC anymore to test on Windows.

Original comment by d...@djm.net.au on 28 Jul 2013 at 12:03

GoogleCodeExporter commented 9 years ago
The u_int8_t, etc. typedefs are in pybc_blf.h but not bcrypt_python.c. Patch 
attached to remedy that.

I do not have MSVC either, this is tested with MinGW.

Original comment by pet...@gmail.com on 28 Jul 2013 at 10:26

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the quick response. Sorry about that, I thought bcrypt_python 
included the header for some reason but it didn't. It does now :) 

Please give tip another try. There is some new code there that may have other 
problems on Windows.

Original comment by d...@djm.net.au on 29 Jul 2013 at 5:24

GoogleCodeExporter commented 9 years ago
Indeed it does. There are three problems, with fixes or advice.

1 u_int*_t missing in places:
Patch pre2 attached which creates pybc_types.h.

2 Various warnings about pointer signedness:
I have not addressed these, you should either fix the declarations or insert 
casts.

3 Error for BYTE_ORDER undefined in sha2.c:
That is tricky to deal with portably in the preprocessor. Patch pre3 uses a 
code snippet I have used in the past which determines endianness at compile 
time.

Original comment by pet...@gmail.com on 29 Jul 2013 at 9:26

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for your patience in testing.

I don't think pre2 is necessary - pybc_sha2.h is only ever included after 
pybc_blf.h which contains the type definitions. The definitions in pybc_blf.h 
were missing u_int64_t for windows systems without stdint.h, so I've added it 
now.

tip also has a slightly different endian test and fixes all the 
pointer-signedness warnings on the platforms I have available.

Could you give it another try?

Original comment by d...@djm.net.au on 29 Jul 2013 at 12:26

GoogleCodeExporter commented 9 years ago
That has fixed the errors and warnings now, thanks. I have successfully built 
and run test/test.py, passing all 5 tests.

Python 2.7.5
Windows 7 64-bit (though using 32 bit Python and py-bcrypt)
MinGW gcc version 4.6.2

Original comment by pet...@gmail.com on 29 Jul 2013 at 1:15

GoogleCodeExporter commented 9 years ago
Excellent - thanks for your help!

Original comment by d...@djm.net.au on 29 Jul 2013 at 10:00