From 125bc5b1a4cf92e251680eb92ae45a1b25aee5cf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 15 Jan 2020 17:53:43 -0800 Subject: [PATCH] dns-query now represents SOA integers as integers (Bug#38937) * lisp/net/dns.el (dns-read-int32): Declare obsolete. Assume bignums. (dns-read-type): Represent SOA integers as integers, not strings. --- etc/NEWS | 5 +++++ lisp/net/dns.el | 16 +++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 3d5915a3774..7ea4bba9cd1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -58,6 +58,11 @@ incorrect hashes for window configurations and some other objects. ** The obsolete function 'thread-alive-p' has been removed. +** dns-query now consistently uses Lisp integers to represent integers. +Formerly it made an exception for integer components of SOA records, +because SOA serial numbers can exceed fixnum ranges on 32-bit platforms. +Emacs now supports bignums so this old glitch is no longer needed. + * Lisp Changes in Emacs 28.1 diff --git a/lisp/net/dns.el b/lisp/net/dns.el index cefe0851f03..78d48271629 100644 --- a/lisp/net/dns.el +++ b/lisp/net/dns.el @@ -258,10 +258,8 @@ If TCP-P, the first two bytes of the package with be the length field." (nreverse spec)))) (defun dns-read-int32 () - ;; Full 32 bit Integers can't be handled by 32-bit Emacsen. If we - ;; use floats, it works. - (format "%.0f" (+ (* (dns-read-bytes 1) 16777216.0) - (dns-read-bytes 3)))) + (declare (obsolete nil "28.1")) + (number-to-string (dns-read-bytes 4))) (defun dns-read-type (string type) (let ((buffer (current-buffer)) @@ -286,11 +284,11 @@ If TCP-P, the first two bytes of the package with be the length field." ((eq type 'SOA) (list (list 'mname (dns-read-name buffer)) (list 'rname (dns-read-name buffer)) - (list 'serial (dns-read-int32)) - (list 'refresh (dns-read-int32)) - (list 'retry (dns-read-int32)) - (list 'expire (dns-read-int32)) - (list 'minimum (dns-read-int32)))) + (list 'serial (dns-read-bytes 4)) + (list 'refresh (dns-read-bytes 4)) + (list 'retry (dns-read-bytes 4)) + (list 'expire (dns-read-bytes 4)) + (list 'minimum (dns-read-bytes 4)))) ((eq type 'SRV) (list (list 'priority (dns-read-bytes 2)) (list 'weight (dns-read-bytes 2)) -- 2.39.5