From cc43a23f29bd144b58a2c33f856f37fce1f60a60 Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 11 Jul 2022 12:55:33 +0800 Subject: [PATCH] vweb: check invalid port number (#15016) --- vlib/vweb/vweb.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 0e55a6db38..574c85554b 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -384,6 +384,9 @@ pub struct RunParams { // Example: vweb.run_at(app, 'localhost', 8099) [manualfree] pub fn run_at(global_app &T, params RunParams) ? { + if params.port <= 0 || params.port > 65535 { + return error('invalid port number `$params.port`, it should be between 1 and 65535') + } mut l := net.listen_tcp(params.family, '$params.host:$params.port') or { ecode := err.code() return error('failed to listen $ecode $err')