dovecot-2.2: var_expand*(): Fixed %N to work the same with littl...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jun 6 12:36:47 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/956324a5fc86
changeset: 16473:956324a5fc86
user: Timo Sirainen <tss at iki.fi>
date: Thu Jun 06 12:36:30 2013 +0300
description:
var_expand*(): Fixed %N to work the same with little and big endian CPUs.
Also use 64bit integer to do the MOD from, which should give somewhat better
value distribution than with 32bit.
diffstat:
src/lib/var-expand.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (28 lines):
diff -r 8f192f64fd98 -r 956324a5fc86 src/lib/var-expand.c
--- a/src/lib/var-expand.c Thu Jun 06 12:24:27 2013 +0300
+++ b/src/lib/var-expand.c Thu Jun 06 12:36:30 2013 +0300
@@ -92,17 +92,21 @@
{
string_t *hash = t_str_new(20);
unsigned char result[MD5_RESULTLEN];
- unsigned int value;
+ unsigned int i;
+ uint64_t value;
md5_get_digest(str, strlen(str), result);
- memcpy(&value, result, sizeof(value));
+ for (i = 0; i < sizeof(value); i++) {
+ value <<= 8;
+ value |= result[i];
+ }
if (ctx->width != 0) {
value %= ctx->width;
ctx->width = 0;
}
- str_printfa(hash, "%x", value);
+ str_printfa(hash, "%x", (unsigned int)value);
while ((int)str_len(hash) < ctx->offset)
str_insert(hash, 0, "0");
ctx->offset = 0;
More information about the dovecot-cvs
mailing list