From: Bob Halley Date: Fri, 19 Jun 2020 14:46:16 +0000 (-0700) Subject: Improve GPOS validity checking. X-Git-Tag: v2.0.0rc1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26a305de96ca67dc88405e2af80723e3bbef7439;p=thirdparty%2Fdnspython.git Improve GPOS validity checking. --- diff --git a/dns/rdtypes/ANY/GPOS.py b/dns/rdtypes/ANY/GPOS.py index 4e9e8192..48a2489a 100644 --- a/dns/rdtypes/ANY/GPOS.py +++ b/dns/rdtypes/ANY/GPOS.py @@ -23,11 +23,16 @@ import dns.tokenizer def _validate_float_string(what): + if len(what) == 0: + raise dns.exception.FormError if what[0] == b'-'[0] or what[0] == b'+'[0]: what = what[1:] if what.isdigit(): return - (left, right) = what.split(b'.') + try: + (left, right) = what.split(b'.') + except ValueError: + raise dns.exception.FormError if left == b'' and right == b'': raise dns.exception.FormError if not left == b'' and not left.decode().isdigit(): @@ -70,6 +75,12 @@ class GPOS(dns.rdata.Rdata): object.__setattr__(self, 'latitude', latitude) object.__setattr__(self, 'longitude', longitude) object.__setattr__(self, 'altitude', altitude) + flat = self.float_latitude + if flat < -90.0 or flat > 90.0: + raise dns.exception.FormError('bad latitude') + flong = self.float_latitude + if flong < -180.0 or flong > 180.0: + raise dns.exception.FormError('bad longitude') def to_text(self, origin=None, relativize=True, **kw): return '{} {} {}'.format(self.latitude.decode(),