From a3838ecfadf1ca2fb826a535355f56082d6cdc22 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 19 Mar 2019 15:21:09 +0100 Subject: [PATCH] error on negative ports --- builder/qemu/builder.go | 4 ++++ builder/vmware/common/run_config.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 7d42939a4..5ca3f555b 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -337,6 +337,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend( errs, errors.New("ssh_host_port_min must be less than ssh_host_port_max")) } + if b.config.SSHHostPortMin < 0 { + errs = packer.MultiErrorAppend( + errs, errors.New("ssh_host_port_min must be positive")) + } if b.config.VNCPortMin > b.config.VNCPortMax { errs = packer.MultiErrorAppend( diff --git a/builder/vmware/common/run_config.go b/builder/vmware/common/run_config.go index e8b6a3d37..da9581427 100644 --- a/builder/vmware/common/run_config.go +++ b/builder/vmware/common/run_config.go @@ -31,6 +31,9 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) { if c.VNCPortMin > c.VNCPortMax { errs = append(errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max")) } + if c.VNCPortMin < 0 { + errs = append(errs, fmt.Errorf("vnc_port_min must be positive")) + } return }