mirror of
https://github.com/vlang/v.git
synced 2025-09-14 23:12:33 +03:00
vweb: check invalid port number (#15016)
This commit is contained in:
parent
bfcf5b13ed
commit
cc43a23f29
1 changed files with 3 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue