From: nbk Date: Sun, 21 Aug 2005 18:12:42 +0000 (+0000) Subject: Pull from CVS head: X-Git-Tag: release_1_0_5~35 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=af0279e03bc8593ad658132a22114feb60baa868;p=freeradius.git Pull from CVS head: Fix an off-by-one error in xlat_copy(). --- diff --git a/src/main/xlat.c b/src/main/xlat.c index ba70150..852bcf3 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -529,30 +529,23 @@ static void decode_attribute(const char **from, char **to, int freespace, */ static int xlat_copy(char *out, int outlen, const char *in) { - int len = 0; + int freespace = outlen; - while (*in) { - /* - * Truncate, if too much. - */ - if (len >= outlen) { - break; - } + rad_assert(outlen >= 0); + while ((*in) && (freespace > 1)) { /* * Copy data. * * FIXME: Do escaping of bad stuff! */ - *out = *in; + *(out++) = *(in++); - out++; - in++; - len++; + freespace--; } - *out = '\0'; - return len; + + return (outlen - freespace); /* count does not include NUL */ } /*