From 8ef4cfa070573256e9770cce2bbd25a73a32c8c7 Mon Sep 17 00:00:00 2001 From: Darwin Liu <76200225+somerandomqaguy@users.noreply.github> Date: Fri, 8 Jan 2021 13:39:17 -0700 Subject: [PATCH] Add in a sanity check for valid vnc ports Check to make sure that the max and min VNC ports be below 65535 in config. --- builder/qemu/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builder/qemu/config.go b/builder/qemu/config.go index 2fc12ab8c..29b0c71ff 100644 --- a/builder/qemu/config.go +++ b/builder/qemu/config.go @@ -599,6 +599,11 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) { errs, fmt.Errorf("vnc_port_min cannot be below 5900")) } + if c.VNCPortMin > 65535 || c.VNCPortMax > 65535 { + errs = packersdk.MultiErrorAppend( + errs, fmt.Errorf("vmc_port_min and vnc_port_max must both be below 65535 to be valid TCP ports")) + } + if c.VNCPortMin > c.VNCPortMax { errs = packersdk.MultiErrorAppend( errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max"))