From e2af2e67aa91f4f22b9d5a1f6808c8de828c12fc Mon Sep 17 00:00:00 2001 From: Ivan Zhakov Date: Thu, 16 May 2019 08:15:34 +0000 Subject: win32: Check return value from apr_generate_random_bytes() in file_pipe_create(). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1859356 13f79535-47bb-0310-9956-ffa450edef68 --- file_io/win32/pipe.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c index 601458258..b13507a91 100644 --- a/file_io/win32/pipe.c +++ b/file_io/win32/pipe.c @@ -120,6 +120,7 @@ static apr_status_t file_pipe_create(apr_file_t **in, (void) apr_pollset_create(&(*out)->pollset, 1, p, 0); #endif if (apr_os_level >= APR_WIN_NT) { + apr_status_t rv; char rand[8]; int pid = getpid(); #define FMT_PIPE_NAME "\\\\.\\pipe\\apr-pipe-%x.%lx." @@ -150,7 +151,12 @@ static apr_status_t file_pipe_create(apr_file_t **in, } dwPipeMode = 0; - apr_generate_random_bytes(rand, sizeof rand); + rv = apr_generate_random_bytes(rand, sizeof rand); + if (rv != APR_SUCCESS) { + file_cleanup(*in); + return rv; + } + pos = apr_snprintf(name, sizeof name, FMT_PIPE_NAME, pid, id++); apr_escape_hex(name + pos, rand, sizeof rand, 0, NULL); @@ -163,7 +169,7 @@ static apr_status_t file_pipe_create(apr_file_t **in, 1, /* nDefaultTimeOut, */ &sa); if ((*in)->filehand == INVALID_HANDLE_VALUE) { - apr_status_t rv = apr_get_os_error(); + rv = apr_get_os_error(); file_cleanup(*in); return rv; } -- cgit v1.2.1