mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: check invalid port number (#15016)
This commit is contained in:
parent
bfcf5b13ed
commit
cc43a23f29
@ -384,6 +384,9 @@ pub struct RunParams {
|
||||
// Example: vweb.run_at(app, 'localhost', 8099)
|
||||
[manualfree]
|
||||
pub fn run_at<T>(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')
|
||||
|
Loading…
Reference in New Issue
Block a user