summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2011-11-04 16:40:25 -0400
committerSimo Sorce <ssorce@redhat.com>2011-11-05 19:05:08 -0400
commit08137836a3ddce17aa5d383a02d177d35b3df266 (patch)
tree2eef39d63eb7a1d4a2d65eb64eae29c655bdbdcf /util
parent9378e8b437a72c7d267def342874a7f2dcaf301c (diff)
downloadfreeipa-08137836a3ddce17aa5d383a02d177d35b3df266.tar.gz
freeipa-08137836a3ddce17aa5d383a02d177d35b3df266.tar.xz
freeipa-08137836a3ddce17aa5d383a02d177d35b3df266.zip
Amend #2038 fix
The math was unsafe, thanks to Nalin for spotting it.
Diffstat (limited to 'util')
-rw-r--r--util/ipa_krb5.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/util/ipa_krb5.c b/util/ipa_krb5.c
index ba9d3cefc..d03680a6e 100644
--- a/util/ipa_krb5.c
+++ b/util/ipa_krb5.c
@@ -13,7 +13,7 @@ static krb5_error_code ipa_get_random_salt(krb5_context krbctx,
krb5_data *salt)
{
krb5_error_code kerr;
- int i;
+ int i, v;
/* make random salt */
salt->length = KRB5P_SALT_SIZE;
@@ -30,8 +30,10 @@ static krb5_error_code ipa_get_random_salt(krb5_context krbctx,
* To avoid any compatibility issue, limits octects only to
* the ASCII printable range, or 0x20 <= val <= 0x7E */
for (i = 0; i < salt->length; i++) {
- salt->data[i] %= 0x5E; /* 7E - 20 */
- salt->data[i] += 0x20; /* add base */
+ v = (unsigned char)salt->data[i];
+ v %= 0x5E; /* 7E - 20 */
+ v += 0x20; /* add base */
+ salt->data[i] = v;
}
return 0;