chiark / gitweb /
adns_processwriteable: assert that write did not write more than we asked
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 1 Dec 2016 02:14:55 +0000 (02:14 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 May 2020 19:23:40 +0000 (20:23 +0100)
This is better than proceeding to make tcpsend.used negative.

Should this ever happens, which it doesn't except under AFL, because
of a bug in hfuzzraw.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/event.c

index 8cfaef5353b54af288e674a7d2d0c816e6dfbc0b..95386f42c4fed8351a939290cd85dcfdf5bed53b 100644 (file)
@@ -488,6 +488,7 @@ int adns_processwriteable(adns_state ads, int fd, const struct timeval *now) {
        adns__tcp_broken(ads,"write",strerror(errno));
        r= 0; goto xit;
       } else if (r>0) {
+       assert(r <= ads->tcpsend.used);
        ads->tcpsend.used -= r;
        memmove(ads->tcpsend.buf,ads->tcpsend.buf+r,ads->tcpsend.used);
       }