summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2019-05-16 08:15:34 +0000
committerIvan Zhakov <ivan@apache.org>2019-05-16 08:15:34 +0000
commite2af2e67aa91f4f22b9d5a1f6808c8de828c12fc (patch)
tree4484ce6081738088d236b113f26cc433797bf185
parent09593ea30b69057e6d4fd1f89ece6dd802610c0e (diff)
downloadapr-e2af2e67aa91f4f22b9d5a1f6808c8de828c12fc.tar.gz
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
-rw-r--r--file_io/win32/pipe.c10
1 files 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;
}