aboutsummaryrefslogtreecommitdiff
path: root/tests/trantest.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2022-12-31 13:55:11 -0800
committerGarrett D'Amore <garrett@damore.org>2022-12-31 13:55:11 -0800
commit539e559e65cd8f227c45e4b046ac41c0edcf6c32 (patch)
tree36eb234d9511bdcc0edf29a4a1a31b427be929fb /tests/trantest.h
parentf26ddeb81a5ea9d316444951f54a2a017db70482 (diff)
downloadnng-539e559e65cd8f227c45e4b046ac41c0edcf6c32.tar.gz
nng-539e559e65cd8f227c45e4b046ac41c0edcf6c32.tar.bz2
nng-539e559e65cd8f227c45e4b046ac41c0edcf6c32.zip
Fixes for some security complaints.
None of these changes are actual security bugs, but GitHub's scanner reports false positives at Critical severity for them. (There are a number of complaints from that scanner, many of which we do not necessarily agree with.)
Diffstat (limited to 'tests/trantest.h')
-rw-r--r--tests/trantest.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/trantest.h b/tests/trantest.h
index be258e28..91b75494 100644
--- a/tests/trantest.h
+++ b/tests/trantest.h
@@ -1,5 +1,5 @@
//
-// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2022 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -45,8 +45,8 @@ unsigned trantest_port = 0;
extern int notransport(void);
extern void trantest_checktran(const char *url);
-extern void trantest_next_address(char *out, const char *template);
-extern void trantest_prev_address(char *out, const char *template);
+extern void trantest_next_address(char *out, const char *prefix);
+extern void trantest_prev_address(char *out, const char *prefix);
extern void trantest_init(trantest *tt, const char *addr);
extern int trantest_dial(trantest *tt, nng_dialer *dp);
extern int trantest_listen(trantest *tt, nng_listener *lp);
@@ -87,9 +87,9 @@ trantest_checktran(const char *url)
}
void
-trantest_next_address(char *out, const char *template)
+trantest_next_address(char *out, const char *prefix)
{
- trantest_checktran(template);
+ trantest_checktran(prefix);
if (trantest_port == 0) {
char *pstr;
@@ -102,15 +102,18 @@ trantest_next_address(char *out, const char *template)
trantest_port = atoi(pstr);
}
}
- (void) snprintf(out, NNG_MAXADDRLEN, template, trantest_port);
+
+ // we append the port, and for web sockets also a /test path
+ (void) snprintf(out, NNG_MAXADDRLEN, "%s%u%s", prefix, trantest_port,
+ prefix[0] == 'w' ? "/test" : "");
trantest_port++;
}
void
-trantest_prev_address(char *out, const char *template)
+trantest_prev_address(char *out, const char *prefix)
{
trantest_port--;
- trantest_next_address(out, template);
+ trantest_next_address(out, prefix);
}
void