]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Correctly encode LOC records with non integer negative altitudes.
authorMark Andrews <marka@isc.org>
Sat, 22 Aug 2020 15:38:17 +0000 (01:38 +1000)
committerOndřej Surý <ondrej@isc.org>
Wed, 26 Aug 2020 14:44:01 +0000 (16:44 +0200)
(cherry picked from commit 337cc878fa5c6a93664b402a5fb7ee06d9b3a0f2)

lib/dns/rdata/generic/loc_29.c

index 96022300c921ed2f559135e0362d371a947a8e5c..ce9235f01af6206fb9841cd17a9a2dd774fb40ab 100644 (file)
@@ -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 @@ getalt:
         */
        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 @@ getalt:
        /*
         * Adjust base.
         */
+       if (m < 0 || negative) {
+               cm = -cm;
+       }
        altitude = m + 100000;
        altitude *= 100;
        altitude += cm;