diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-12-20 14:20:37 -0500 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-12-20 14:28:32 -0500 |
commit | 7506becc0ac70915050e097d673e7647b99347fc (patch) | |
tree | a1b51a8de6b305d2182083334a5eb29bef8dddfb /src | |
parent | 41b35299cbfa6a47e93f56344cd2e52dd4418ce6 (diff) | |
download | krb5-7506becc0ac70915050e097d673e7647b99347fc.zip krb5-7506becc0ac70915050e097d673e7647b99347fc.tar.gz krb5-7506becc0ac70915050e097d673e7647b99347fc.tar.bz2 |
Fix signed overflow check in k5_ucs2s_to_utf8s
Signed overflow must be checked before it happens, since modern
versions of gcc will optimize out checks of the result. Reported by
Nickolai Zeldovich <nickolai@csail.mit.edu>.
ticket: 7511
Diffstat (limited to 'src')
-rw-r--r-- | src/util/support/utf8_conv.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/util/support/utf8_conv.c b/src/util/support/utf8_conv.c index 6e7c588..d580bbc 100644 --- a/src/util/support/utf8_conv.c +++ b/src/util/support/utf8_conv.c @@ -276,10 +276,8 @@ k5_ucs2s_to_utf8s(char *utf8str, const krb5_ucs2 *ucs2str, #endif n = krb5int_ucs2_to_utf8(ch, NULL); - if (n < 1) + if (n < 1 || n > INT_MAX - len) return -1; - if (len + n < len) - return -1; /* overflow */ len += n; } |