aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2015-09-25 17:31:53 -0400
committerTom Yu <tlyu@mit.edu>2015-12-10 17:34:13 -0500
commitfdbac6f2bbbe4673359760f2170770aa93044882 (patch)
tree2dc5327c13ee1a1dcafdac122f26b759257c60ee
parent0d8e70728f7bc74554414fef9a1fcaca672a4d5b (diff)
downloadkrb5-fdbac6f2bbbe4673359760f2170770aa93044882.zip
krb5-fdbac6f2bbbe4673359760f2170770aa93044882.tar.gz
krb5-fdbac6f2bbbe4673359760f2170770aa93044882.tar.bz2
Fix minor utf8-to-ucs2s read overrun bug
k5_utf8s_to_ucs2s() reads and ignores one extra byte from the input string before terminating its loop, possibly overrunning the input buffer of its caller. This overrun is typically without consequence, but can show up in tools like asan or valgrind during RC4 string-to-key operations. Fix the bug by swapping the order of the loop conditions. (cherry picked from commit eb52da21d72faa3d00b1205a5a0fdbabc45c9e6d) ticket: 8321 (new) version_fixed: 1.12.5 status: resolved
-rw-r--r--src/util/support/utf8_conv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util/support/utf8_conv.c b/src/util/support/utf8_conv.c
index b8bf989..8fa2ce0 100644
--- a/src/util/support/utf8_conv.c
+++ b/src/util/support/utf8_conv.c
@@ -85,7 +85,7 @@ k5_utf8s_to_ucs2s(krb5_ucs2 *ucs2str,
}
/* Examine next UTF-8 character. */
- while (*utf8str && ucs2len < count) {
+ while (ucs2len < count && *utf8str != '\0') {
/* Get UTF-8 sequence length from 1st byte */
utflen = KRB5_UTF8_CHARLEN2(utf8str, utflen);