From 1edb726c0bdc3110e3962bcd845bc106de860515 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Sun, 10 Aug 2014 03:50:46 +0000 Subject: [PATCH] opts.IPVal returns an error on incorrect input Signed-off-by: Solomon Hykes --- opts/ip.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/opts/ip.go b/opts/ip.go index 3610b14538..f0c29750bc 100644 --- a/opts/ip.go +++ b/opts/ip.go @@ -1,6 +1,7 @@ package opts import ( + "fmt" "net" ) @@ -17,8 +18,10 @@ func NewIpOpt(ref *net.IP, defaultVal string) *IpOpt { } func (o *IpOpt) Set(val string) error { - // FIXME: return a parse error if the value is not a valid IP? - // We are not changing this now to preserve behavior while refactoring. + ip := net.ParseIP(val) + if ip == nil { + return fmt.Errorf("incorrect IP format") + } (*o.IP) = net.ParseIP(val) return nil }