]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Forbid isc_buffer_printf from growing the buffer unless auto reallocation is enabled
authorOndřej Surý <ondrej@sury.org>
Fri, 27 Jul 2018 09:22:47 +0000 (11:22 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 31 Jul 2018 20:00:30 +0000 (22:00 +0200)
lib/isc/buffer.c

index 79b64d75c4f9f8a89f41f53dac0db15370357bb4..cecfecddd9348e16a0003316c30bdf34f692149d 100644 (file)
@@ -662,9 +662,15 @@ isc_buffer_printf(isc_buffer_t *b, const char *format, ...) {
                return (ISC_R_FAILURE);
        }
 
-       result = isc_buffer_reserve(&b, n + 1);
-       if (result != ISC_R_SUCCESS) {
-               return (result);
+       if (ISC_UNLIKELY(b->autore)) {
+               result = isc_buffer_reserve(&b, n + 1);
+               if (result != ISC_R_SUCCESS) {
+                       return (result);
+               }
+       }
+
+       if (isc_buffer_availablelength(b) < (unsigned int)n + 1) {
+               return (ISC_R_NOSPACE);
        }
 
        va_start(ap, format);