Commit Graph

8 Commits

Author SHA1 Message Date
David Zarzycki
1473e20c15 [Runtime] NFC: Fix -Wgnu-statement-expression warning 2019-08-19 08:10:49 +01:00
Cory Benfield
c2b6c8aa16 Avoid uninitialized "random" bytes on Windows.
__swift_size_t on Windows is a size_t, which makes it potentially a
64-bit integer. ULONG, however, is always a 32-bit integer, and so this
cast risks shrinking the apparent size of the cbBuffer argument to
BCryptGenRandom. The effect of that will be to underfill the buffer,
leaving it full of uninitialized memory that we would treat as random.

The actual risk from this in the current implementation is basically
zero, as user code can only ever invoke this with an argument size of 8.
There's no good reason to leave this sharp edge on the API though.
2019-07-23 17:50:34 +01:00
Saleem Abdulrasool
68ec9d4a0f stdlib: correct case for the bcrypt import library
On Windows the filesystem is not case sensitive and this will link just fine.
However, the Windows SDK provides the import library with the lowercase name.
Adjust the name so that the link actually succeeds on case-sensitive file
systems (like on Linux).  This fixes the Windows cross-compile.
2018-10-05 11:21:20 -07:00
Saleem Abdulrasool
6729aacaef stdlib: include "Windows.h" before "Bcrypt.h"
The system header depends on Windows.h but does not include it itself.  This
results in base Windows types (e.g. ULONG) to be undefined.  Include the header
to include the needed typedefs.
2018-10-05 11:20:23 -07:00
Mike Ash
1e9741a3f8 [Stdlib] Fix Linux detection for malloc_size. Silence const cast warnings. Fix Linux implementation in Random.cpp to actually compile. 2018-10-03 14:31:39 -04:00
Mike Ash
5391abbf4b [Stdlib] Clean up includes in LibcShims and Random. 2018-10-03 11:16:37 -04:00
Mike Ash
c4d5db404b [Stdlib] Change _swift_stdlib_random SPI to swift_stdlib_random API. 2018-10-03 09:55:34 -04:00
Mike Ash
6926fbd363 [Stdlib] Pull _swift_stdlib_random into a separate file. 2018-10-03 09:55:34 -04:00