openbsd-ports/textproc/libxml/patches/patch-encoding_c

28 lines
1.0 KiB
Plaintext
Raw Normal View History

$OpenBSD: patch-encoding_c,v 1.1 2012/01/23 10:17:49 ajacoutot Exp $
From 69f04562f75212bfcabecd190ea8b06ace28ece2 Mon Sep 17 00:00:00 2001
From: Daniel Veillard <veillard@redhat.com>
Date: Fri, 19 Aug 2011 03:05:04 +0000
Subject: Fix an off by one error in encoding
--- encoding.c.orig Thu Nov 4 17:40:06 2010
+++ encoding.c Mon Jan 23 08:06:05 2012
@@ -1928,7 +1928,7 @@ xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler
if (in == NULL) return(-1);
/* calculate space available */
- written = out->size - out->use;
+ written = out->size - out->use - 1; /* count '\0' */
toconv = in->use;
/*
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
@@ -2059,7 +2059,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xml
toconv = in->use;
if (toconv == 0)
return (0);
- written = out->size - out->use;
+ written = out->size - out->use -1; /* count '\0' */
if (toconv * 2 >= written) {
xmlBufferGrow(out, out->size + toconv * 2);
written = out->size - out->use - 1;