X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcstringprep.c;h=b1716cc501f0c783042b34a4e2ceb6db16882324;hp=18ec3e94c889a648886ebaa47d394c1de904ddd1;hb=52e57c880aba9c5e89f59d962eb9af75670b76e0;hpb=ae1482a76c29db9fdcd6ed6cf63d312a37a5cb01 diff --git a/lib/silcutil/silcstringprep.c b/lib/silcutil/silcstringprep.c index 18ec3e94..b1716cc5 100644 --- a/lib/silcutil/silcstringprep.c +++ b/lib/silcutil/silcstringprep.c @@ -186,7 +186,7 @@ silc_stringprep(const unsigned char *bin, SilcUInt32 bin_len, f |= STRINGPREP_NO_UNASSIGNED; /* Prepare */ - ret = stringprep((char *)utf8s, utf8s_len + 1, f, profile); + ret = stringprep((char *)utf8s, utf8s_len, f, profile); SILC_LOG_DEBUG(("stringprep() return %d", ret)); /* Since the stringprep() doesn't allocate returned buffer, and @@ -194,10 +194,10 @@ silc_stringprep(const unsigned char *bin, SilcUInt32 bin_len, much space we must have for the conversion. Allocate more if it fails, and try again. */ if (ret == STRINGPREP_TOO_SMALL_BUFFER) { - utf8s = silc_realloc(utf8s, sizeof(*utf8s) * (utf8s_len * 2)); + utf8s = silc_realloc(utf8s, sizeof(*utf8s) * ((utf8s_len * 2) + 1)); if (!utf8s) return SILC_STRINGPREP_ERR_OUT_OF_MEMORY; - memset(utf8s + utf8s_len, 0, utf8s_len); + memset(utf8s + utf8s_len + 1, 0, utf8s_len); ret = stringprep((char *)utf8s, utf8s_len * 2, f, profile); SILC_LOG_DEBUG(("stringprep() return %d", ret)); }