Fossil SCM
Fix gcc-4.7.2 warning: src/md5.c: In functie 'MD5Final': src/md5.c:263:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] src/md5.c:264:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
Commit
98fd649a9af410e885b8aa498fb7dda79532dc2b
Parent
30a63b8b66f176d…
1 file changed
+1
-2
+1
-2
| --- src/md5.c | ||
| +++ src/md5.c | ||
| @@ -258,12 +258,11 @@ | ||
| 258 | 258 | memset(p, 0, count-8); |
| 259 | 259 | } |
| 260 | 260 | byteReverse(ctx->in, 14); |
| 261 | 261 | |
| 262 | 262 | /* Append length in bits and transform */ |
| 263 | - ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0]; | |
| 264 | - ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1]; | |
| 263 | + memcpy(&ctx->in[14*sizeof(uint32)], ctx->bits, 2*sizeof(uint32)); | |
| 265 | 264 | |
| 266 | 265 | MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| 267 | 266 | byteReverse((unsigned char *)ctx->buf, 4); |
| 268 | 267 | memcpy(digest, ctx->buf, 16); |
| 269 | 268 | memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ |
| 270 | 269 |
| --- src/md5.c | |
| +++ src/md5.c | |
| @@ -258,12 +258,11 @@ | |
| 258 | memset(p, 0, count-8); |
| 259 | } |
| 260 | byteReverse(ctx->in, 14); |
| 261 | |
| 262 | /* Append length in bits and transform */ |
| 263 | ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0]; |
| 264 | ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1]; |
| 265 | |
| 266 | MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| 267 | byteReverse((unsigned char *)ctx->buf, 4); |
| 268 | memcpy(digest, ctx->buf, 16); |
| 269 | memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ |
| 270 |
| --- src/md5.c | |
| +++ src/md5.c | |
| @@ -258,12 +258,11 @@ | |
| 258 | memset(p, 0, count-8); |
| 259 | } |
| 260 | byteReverse(ctx->in, 14); |
| 261 | |
| 262 | /* Append length in bits and transform */ |
| 263 | memcpy(&ctx->in[14*sizeof(uint32)], ctx->bits, 2*sizeof(uint32)); |
| 264 | |
| 265 | MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| 266 | byteReverse((unsigned char *)ctx->buf, 4); |
| 267 | memcpy(digest, ctx->buf, 16); |
| 268 | memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ |
| 269 |