From 73267db52dc7917dbed341d874c7f45255e5b9ab Mon Sep 17 00:00:00 2001 From: Igor Zlatkovic Date: Sat, 8 Mar 2003 13:29:24 +0000 Subject: [PATCH] applied Gennady's patch against buffer overrun --- encoding.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/encoding.c b/encoding.c index 3ac35fd3..de55e2e0 100644 --- a/encoding.c +++ b/encoding.c @@ -2194,6 +2194,9 @@ retry: written = out->size - out->use; + if (written > 0) + written--; /* Gennady: count '/0' */ + /* * First specific handling of in = NULL, i.e. the initialization call */ @@ -2202,8 +2205,10 @@ retry: if (handler->output != NULL) { ret = handler->output(&out->content[out->use], &written, NULL, &toconv); - out->use += written; - out->content[out->use] = 0; + if (ret == 0) { /* Gennady: check return value */ + out->use += written; + out->content[out->use] = 0; + } } #ifdef LIBXML_ICONV_ENABLED else if (handler->iconv_out != NULL) {