From 74782cc76967e5efeca492ca875adc517dbfb02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sun, 3 Feb 2008 17:35:06 +0000 Subject: [PATCH] Fix overaggressive checks, fix comments. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22560 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/wind/utf8.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/wind/utf8.c b/lib/wind/utf8.c index 7ca97aac1..d09c44370 100644 --- a/lib/wind/utf8.c +++ b/lib/wind/utf8.c @@ -148,10 +148,12 @@ static const char first_char[4] = * * @param in an UCS4 string to convert. * @param in_len the length input array. + * @param out the resulting UTF-8 strint, must be at least - * wind_ucs4utf8_length() long. If out is NULL, the function will - * calculate the needed space for the out variable (just like - * wind_ucs4utf8_length()). + * wind_ucs4utf8_length() + 1 long (the extra char for the NUL). If + * out is NULL, the function will calculate the needed space for the + * out variable (just like wind_ucs4utf8_length()). + * @param out_len before processing out_len should be the length of * the out variable, after processing it will be the length of the out * string. @@ -410,11 +412,11 @@ wind_ucs2utf8(const uint16_t *in, size_t in_len, char *out, size_t *out_len) case 1: out[0] = ch | first_char[len - 1]; } + out += len; } - out += len; } if (out) { - if (o + 1 >= *out_len) + if (o >= *out_len) return WIND_ERR_OVERRUN; *out = '\0'; }