From: Ian Jackson Date: Thu, 1 Dec 2016 02:14:55 +0000 (+0000) Subject: adns_processwriteable: assert that write did not write more than we asked X-Git-Tag: adns-1.5.2~15 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=1b7cf52f87fe744219d2921aa4b95012171f0467;hp=f14a3d1bd8501b7a1055f5adb53731da96ef0465;p=adns.git adns_processwriteable: assert that write did not write more than we asked 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 --- diff --git a/src/event.c b/src/event.c index 8cfaef5..95386f4 100644 --- a/src/event.c +++ b/src/event.c @@ -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); }