From 876449e105236df4b06eabdb580d92b291d8f948 Mon Sep 17 00:00:00 2001 From: buffermet <29265684+buffermet@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:37:16 +0100 Subject: [PATCH] Fix backwards compatible uint64 conversion --- modules/dns_proxy/dns_proxy_js_query.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/dns_proxy/dns_proxy_js_query.go b/modules/dns_proxy/dns_proxy_js_query.go index 64ea9052..535a153f 100644 --- a/modules/dns_proxy/dns_proxy_js_query.go +++ b/modules/dns_proxy/dns_proxy_js_query.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "math" + "math/big" "github.com/bettercap/bettercap/v2/log" "github.com/bettercap/bettercap/v2/session" @@ -138,9 +139,11 @@ func jsPropToUint32(obj map[string]interface{}, key string) uint32 { } func jsPropToUint64(obj map[string]interface{}, key string) uint64 { - if v, ok := obj[key].(int64); ok { + if f, ok := obj[key].(float64); ok { + bigInt := new(big.Float).SetFloat64(f) + v, _ := bigInt.Uint64() if v >= 0 { - return uint64(v) + return v } } log.Error("error converting JS property to uint64 where key is: %s", key)