bind/backport-0028-Correctly-encode-LOC-records-with-non-integer-negati.patch
jiangheng ad37c37958 backport some patches from community
(cherry picked from commit a9fd9ece9b9436b6103d084920c6897ef1adbae6)
2022-09-03 21:36:21 +08:00

49 lines
1.3 KiB
Diff

From 19b95a5f372b0b621a16699d7e6ebb2717a31314 Mon Sep 17 00:00:00 2001
From: Mark Andrews <marka@isc.org>
Date: Sun, 23 Aug 2020 01:38:17 +1000
Subject: [PATCH] Correctly encode LOC records with non integer negative
altitudes.
(cherry picked from commit 337cc878fa5c6a93664b402a5fb7ee06d9b3a0f2)
Conflict: modify seg2
Reference: https://gitlab.isc.org/isc-projects/bind9/-/commit/19b95a5f372b0b621a16699d7e6ebb2717a31314
---
lib/dns/rdata/generic/loc_29.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c
index 0ef4360ffe..1e29d92ba9 100644
--- a/lib/dns/rdata/generic/loc_29.c
+++ b/lib/dns/rdata/generic/loc_29.c
@@ -27,6 +27,7 @@ fromtext_loc(ARGS_FROMTEXT) {
unsigned char version;
bool east = false;
bool north = false;
+ bool negative = false;
long tmp;
long m;
long cm;
@@ -280,6 +281,9 @@ fromtext_loc(ARGS_FROMTEXT) {
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
+ if (DNS_AS_STR(token)[0] == '-') {
+ negative = true;
+ }
m = strtol(DNS_AS_STR(token), &e, 10);
if (*e != 0 && *e != '.' && *e != 'm')
RETTOK(DNS_R_SYNTAX);
@@ -324,6 +328,9 @@ fromtext_loc(ARGS_FROMTEXT) {
/*
* Adjust base.
*/
+ if (m < 0 || negative) {
+ cm = -cm;
+ }
altitude = m + 100000;
altitude *= 100;
altitude += cm;
--
2.23.0