From c9cb45bbcfcd5297e9f34b46a1cb6d9b17384042 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 4 May 2008 21:49:59 +0000 Subject: [PATCH] cope with 0-length messages in oprintf, and do tryflush just before bombing due to buffer overflow --- hostside/obc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hostside/obc.c b/hostside/obc.c index 6eafc19..c522afb 100644 --- a/hostside/obc.c +++ b/hostside/obc.c @@ -78,6 +78,7 @@ static void addlink(OutBufferChain *ch, OutBuffer *ob) { char what[128]; snprintf(what,sizeof(what)-1,"`%.*s...'", ob->l,ob->m); what[sizeof(what)-1]= 0; + obc_tryflush(ch); ch->error(ch,"buffer limit exceeded",what); } } @@ -100,7 +101,9 @@ void ovprintf(OutBufferChain *ch, const char *fmt, va_list al) { OutBuffer *ob; ob= mmalloc(sizeof(*ob)); - ob->l= vasprintf(&ob->m, fmt, al); if (ob->l <= 0) diem(); + ob->l= vasprintf(&ob->m, fmt, al); + if (ob->l < 0) diem(); + if (!ob->l) { free(ob->m); free(ob); return; } addlink(ch, ob); } -- 2.30.2