]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Grow the lex token buffer in one more place
authorMark Andrews <marka@isc.org>
Mon, 28 Feb 2022 00:47:56 +0000 (11:47 +1100)
committerMark Andrews <marka@isc.org>
Wed, 2 Mar 2022 01:04:40 +0000 (01:04 +0000)
when parsing key pairs, if the '=' character fell at max_token
a protective INSIST preventing buffer overrun could be triggered.
Attempt to grow the buffer immediately before the INSIST.

Also removed an unnecessary INSIST on the opening double quote
of key buffer pair.

(cherry picked from commit 4c356d277002d3e2f60fe43aaa85a4d524d933f8)

lib/isc/lex.c

index 954655380004c003e1a50fd945a98bd9022f4c93..aa9b549f799294f2e4f0b0dda41bb23f74b38b95 100644 (file)
@@ -670,6 +670,13 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
                case lexstate_string:
                        if (!escaped && c == '=' &&
                            (options & ISC_LEXOPT_VPAIR) != 0) {
+                               if (remaining == 0U) {
+                                       result = grow_data(lex, &remaining,
+                                                          &curr, &prev);
+                                       if (result != ISC_R_SUCCESS) {
+                                               goto done;
+                                       }
+                               }
                                INSIST(remaining > 0U);
                                *curr++ = c;
                                *curr = '\0';
@@ -682,7 +689,6 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
                        if (state == lexstate_vpairstart) {
                                if (c == '"' &&
                                    (options & ISC_LEXOPT_QVPAIR) != 0) {
-                                       INSIST(remaining > 0U);
                                        no_comments = true;
                                        state = lexstate_qvpair;
                                        break;