From 4b68e14039aa3aa9385c0849f1482d26d6f69a53 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 1 Jul 2021 09:30:02 -0400 Subject: [PATCH] Fix codeql errors (#1181) --- pkg/transform/ptr.go | 9 +++------ providers/msdns/naptr.go | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/transform/ptr.go b/pkg/transform/ptr.go index d2eb8219a..06a1d2b9d 100644 --- a/pkg/transform/ptr.go +++ b/pkg/transform/ptr.go @@ -4,7 +4,6 @@ import ( "fmt" "net" "regexp" - "strconv" "strings" ) @@ -89,12 +88,10 @@ func ipMatchesClasslessDomain(ip net.IP, domain string) bool { // atob converts a to a byte value or panics. func atob(s string) uint8 { - if i, err := strconv.Atoi(s); err == nil { - if i < 256 { - return byte(i) - } + if i, err := ParseUint(s, 10, 8); err == nil { + return byte(i) } - panic(fmt.Sprintf("(%v) matched \\d{1,3} but is not a byte", s)) + panic(fmt.Sprintf("%v is not a byte", s)) } func ipv6magic(name, domain string) (string, error) { diff --git a/providers/msdns/naptr.go b/providers/msdns/naptr.go index 169df7568..38a7044d7 100644 --- a/providers/msdns/naptr.go +++ b/providers/msdns/naptr.go @@ -86,7 +86,7 @@ func decodeRecordDataNaptr(s string) models.RecordConfig { // eatUint16 consumes the first 16 bits of the string, returns it as a // uint16, and returns the remaining bytes of the string. func eatUint16(s string) (string, uint16) { - value, err := strconv.ParseUint(s[2:4]+s[0:2], 16, 64) + value, err := strconv.ParseUint(s[2:4]+s[0:2], 16, 16) if err != nil { log.Fatal(err) }