From 5bdf4c6143899ed0d21a220c238b6e2aae0de2f6 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 12 Dec 2015 09:55:37 -0800 Subject: [PATCH] upnp: Use a separate error for the error unmarshalling Previously, when unmarshing the SOAP error code data we would overwrite the original err, typically with null since the parsing of the error code information succeeds. If we don't have a upnp 725 error, we would fall back to returning null or no error. This broke our upnp error handling logic for AddPortMappings as it would think it succeeds if it gets a 718 permission error. --- lib/upnp/upnp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index 6031d1468..c5456281a 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -531,9 +531,9 @@ func (s *IGDService) AddPortMapping(localIPAddress string, protocol Protocol, ex if err != nil && timeout > 0 { // Try to repair error code 725 - OnlyPermanentLeasesSupported envelope := &soapErrorResponse{} - err = xml.Unmarshal(response, envelope) - if err != nil { - return err + err2 := xml.Unmarshal(response, envelope) + if err2 != nil { + return err2 } if envelope.ErrorCode == 725 { return s.AddPortMapping(localIPAddress, protocol, externalPort, internalPort, description, 0)