]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #379: zone loading over HTTP appears to have buffer issues.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 6 Jan 2021 09:36:23 +0000 (10:36 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 6 Jan 2021 09:36:23 +0000 (10:36 +0100)
doc/Changelog
util/netevent.c

index a596befee8b34c11e9e5a318b30ad12f824751a1..b450e75e2f5a1de9a3ee5eed75e8608e081abaeb 100644 (file)
@@ -1,3 +1,6 @@
+6 January 2021: Wouter
+       - Fix #379: zone loading over HTTP appears to have buffer issues.
+
 5 January 2021: Wouter
        - Fix #385: autoconf 2.70 impacts unbound build
        - Merge PR #375 by fhriley: Add rpz_enable and rpz_disable commands
index 5c75508054af297ae2033c802510f8323cf1238e..a5c3fe6667db7147bb6176580ed5ee1c74abe426 100644 (file)
@@ -2412,7 +2412,7 @@ http_nonchunk_segment(struct comm_point* c)
        return 1;
 }
 
-/** handle nonchunked data segment, return 0=fail, 1=wait, 2=process more */
+/** handle chunked data segment, return 0=fail, 1=wait, 2=process more */
 static int
 http_chunked_segment(struct comm_point* c)
 {
@@ -2422,6 +2422,7 @@ http_chunked_segment(struct comm_point* c)
         */
        size_t remainbufferlen;
        size_t got_now = sldns_buffer_limit(c->buffer) - c->http_stored;
+       verbose(VERB_ALGO, "http_chunked_segment: got now %d, tcpbytcount %d, http_stored %d, buffer pos %d, buffer limit %d", (int)got_now, (int)c->tcp_byte_count, (int)c->http_stored, (int)sldns_buffer_position(c->buffer), (int)sldns_buffer_limit(c->buffer));
        if(c->tcp_byte_count <= got_now) {
                /* the chunk has completed (with perhaps some extra data
                 * from next chunk header and next chunk) */
@@ -2761,6 +2762,11 @@ comm_point_http_handle_read(int fd, struct comm_point* c)
        }
 
        sldns_buffer_flip(c->buffer);
+       /* if we are partway in a segment of data, position us at the point
+        * where we left off previously */
+       if(c->http_stored < sldns_buffer_limit(c->buffer))
+               sldns_buffer_set_position(c->buffer, c->http_stored);
+       else    sldns_buffer_set_position(c->buffer, sldns_buffer_limit(c->buffer));
 
        while(sldns_buffer_remaining(c->buffer) > 0) {
                /* Handle HTTP/1.x data */