diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-24 12:41:19 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-01-24 13:07:11 +0000 |
commit | 6422b0ef38d0835c86b40e6e642f18cdfb933e85 (patch) | |
tree | 4e235a00fe2f61e7c4466272b52b943e9117270a | |
parent | 3c85cc0c4821f7131d90f5010b2930bdb0eae4d4 (diff) | |
download | busybox-w32-6422b0ef38d0835c86b40e6e642f18cdfb933e85.tar.gz busybox-w32-6422b0ef38d0835c86b40e6e642f18cdfb933e85.tar.bz2 busybox-w32-6422b0ef38d0835c86b40e6e642f18cdfb933e85.zip |
tls: avoid unnecessary changes to POSIX build
Calls to tls_error_die() embed the line number of the error in the
binary. Since some lines had been added to tls.c for the WIN32
port a POSIX build of the busybox-w32 source differed from upstream.
Avoid this by pushing the special handling of /dev/urandom down into
open_read_close(). tls.c is now unchanged from upstream.
The only differences in the POSIX build reported by 'objdump -s'
are now the GNU build id, the copyright date and the date of the
configuration.
-rw-r--r-- | libbb/read.c | 7 | ||||
-rw-r--r-- | networking/tls.c | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libbb/read.c b/libbb/read.c index a342506a8..2e4317cd5 100644 --- a/libbb/read.c +++ b/libbb/read.c | |||
@@ -73,7 +73,14 @@ ssize_t FAST_FUNC read_close(int fd, void *buf, size_t size) | |||
73 | 73 | ||
74 | ssize_t FAST_FUNC open_read_close(const char *filename, void *buf, size_t size) | 74 | ssize_t FAST_FUNC open_read_close(const char *filename, void *buf, size_t size) |
75 | { | 75 | { |
76 | #if !ENABLE_PLATFORM_MINGW32 | ||
76 | int fd = open(filename, O_RDONLY); | 77 | int fd = open(filename, O_RDONLY); |
78 | #else | ||
79 | int fd, flag; | ||
80 | |||
81 | flag = O_RDONLY | (get_dev_type(filename) == DEV_URANDOM ? O_SPECIAL : 0); | ||
82 | fd = mingw_open(filename, flag); | ||
83 | #endif | ||
77 | if (fd < 0) | 84 | if (fd < 0) |
78 | return fd; | 85 | return fd; |
79 | return read_close(fd, buf, size); | 86 | return read_close(fd, buf, size); |
diff --git a/networking/tls.c b/networking/tls.c index 869456a6a..e34acd69f 100644 --- a/networking/tls.c +++ b/networking/tls.c | |||
@@ -349,14 +349,8 @@ static void dump_tls_record(const void *vp, int len) | |||
349 | 349 | ||
350 | void FAST_FUNC tls_get_random(void *buf, unsigned len) | 350 | void FAST_FUNC tls_get_random(void *buf, unsigned len) |
351 | { | 351 | { |
352 | #if !ENABLE_PLATFORM_MINGW32 | ||
353 | if (len != open_read_close("/dev/urandom", buf, len)) | 352 | if (len != open_read_close("/dev/urandom", buf, len)) |
354 | xfunc_die(); | 353 | xfunc_die(); |
355 | #else | ||
356 | int fd = mingw_open("/dev/urandom", O_RDONLY|O_SPECIAL); | ||
357 | if (fd < 0 || len != read_close(fd, buf, len)) | ||
358 | xfunc_die(); | ||
359 | #endif | ||
360 | } | 354 | } |
361 | 355 | ||
362 | static void xorbuf3(void *dst, const void *src1, const void *src2, unsigned count) | 356 | static void xorbuf3(void *dst, const void *src1, const void *src2, unsigned count) |