summaryrefslogtreecommitdiff
path: root/lib9p/tests/test_server/main.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-22 18:51:59 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-06 11:53:17 -0600
commit24e5d0ec1219e2dbb4b9510ef20833092a2b3871 (patch)
tree01bbcc34c6190fa1c35b2625e9ba1744b1447606 /lib9p/tests/test_server/main.c
parentf09b7435b3a5222597d27238226d23ec0cbd5bd2 (diff)
wip: Build with -Wconversionlukeshu/safe-conversion
I think this found a real bug in the dhcp packet parser. I don't think anything called lib9p_str{,n}() values that could be big enough, but their bounds-checking was broken.
Diffstat (limited to 'lib9p/tests/test_server/main.c')
-rw-r--r--lib9p/tests/test_server/main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c
index d7819eb..8490d62 100644
--- a/lib9p/tests/test_server/main.c
+++ b/lib9p/tests/test_server/main.c
@@ -151,7 +151,11 @@ int main(int argc, char *argv[]) {
if (argc != 3)
error(2, 0, "usage: %s PORT_NUMBER LOGFILE", argv[0]);
- globals.port = atoi(argv[1]);
+ int _port = atoi(argv[1]);
+ if (_port == 0 || _port > UINT16_MAX)
+ error(2, 0, "usage: %s PORT_NUMBER LOGFILE", argv[0]);
+
+ globals.port = (uint16_t)_port;
globals.logstream = fopen(argv[2], "w");
if (!globals.logstream)
error(2, errno, "fopen");