~ubuntu-branches/ubuntu/precise/pam-pgsql/precise

« back to all changes in this revision

Viewing changes to debian/patches/md5_64bit_584683.patch

  • Committer: Bazaar Package Importer
  • Author(s): Jan Dittberner
  • Date: 2010-09-11 21:51:41 UTC
  • mfrom: (2.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100911215141-mg0sfhma27plr7hx
Tags: 0.7.1-4
* update DEP-3 information in
  debian/patches/md5postgres_594721.patch, and fix a typo
* add debian/NEWS to notify about the change of default pw_type

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 30361fa5f3266c0f088bbc89eb06dddbd032fc54 Mon Sep 17 00:00:00 2001
 
2
From: =?utf-8?q?Diego=20Elio=20'Flameeyes'=20Petten=C3=B2?= <flameeyes@gmail.com>
 
3
Date: Wed, 7 Apr 2010 15:58:04 +0200
 
4
Subject: [PATCH] Fix md5 code under 64-bit platforms.
 
5
 
 
6
The code was previously singling out the Alpha platform as 64-bit, but
 
7
that's definitely not the only platform where unsigned long is 64-bit
 
8
rather than 32.
 
9
 
 
10
This change actually relies on C89 standard integers (uint32_t) so that
 
11
there is no more risk of getting it wrong.
 
12
---
 
13
 src/md5.c |   28 ++++++++++++++--------------
 
14
 src/md5.h |   10 +++-------
 
15
 2 files changed, 17 insertions(+), 21 deletions(-)
 
16
 
 
17
diff --git a/src/md5.c b/src/md5.c
 
18
index 3b51e76..df24f16 100644
 
19
--- a/src/md5.c
 
20
+++ b/src/md5.c
 
21
@@ -17,7 +17,7 @@
 
22
 #include <string.h>            /* for memcpy() */
 
23
 #include "md5.h"
 
24
 
 
25
-static void MD5Transform(uint32 buf[4], uint32 const in[16]);
 
26
+static void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
 
27
 
 
28
 #ifndef HIGHFIRST
 
29
 #define byteReverse(buf, len)  /* Nothing */
 
30
@@ -30,11 +30,11 @@ void byteReverse(unsigned char *buf, unsigned longs);
 
31
  */
 
32
 void byteReverse(unsigned char *buf, unsigned longs)
 
33
 {
 
34
-    uint32 t;
 
35
+    uint32_t t;
 
36
     do {
 
37
-       t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
 
38
+       t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
 
39
            ((unsigned) buf[1] << 8 | buf[0]);
 
40
-       *(uint32 *) buf = t;
 
41
+       *(uint32_t *) buf = t;
 
42
        buf += 4;
 
43
     } while (--longs);
 
44
 }
 
45
@@ -62,12 +62,12 @@ void MD5Init(struct MD5Context *ctx)
 
46
  */
 
47
 void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 
48
 {
 
49
-    uint32 t;
 
50
+    uint32_t t;
 
51
 
 
52
     /* Update bitcount */
 
53
 
 
54
     t = ctx->bits[0];
 
55
-    if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
 
56
+    if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
 
57
        ctx->bits[1]++;         /* Carry from low to high */
 
58
     ctx->bits[1] += len >> 29;
 
59
 
 
60
@@ -85,7 +85,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 
61
        }
 
62
        memcpy(p, buf, t);
 
63
        byteReverse(ctx->in, 16);
 
64
-       MD5Transform(ctx->buf, (uint32 *) ctx->in);
 
65
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
 
66
        buf += t;
 
67
        len -= t;
 
68
     }
 
69
@@ -94,7 +94,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
 
70
     while (len >= 64) {
 
71
        memcpy(ctx->in, buf, 64);
 
72
        byteReverse(ctx->in, 16);
 
73
-       MD5Transform(ctx->buf, (uint32 *) ctx->in);
 
74
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
 
75
        buf += 64;
 
76
        len -= 64;
 
77
     }
 
78
@@ -129,7 +129,7 @@ void MD5Final(unsigned char *digest, struct MD5Context *ctx)
 
79
        /* Two lots of padding:  Pad the first block to 64 bytes */
 
80
        memset(p, 0, count);
 
81
        byteReverse(ctx->in, 16);
 
82
-       MD5Transform(ctx->buf, (uint32 *) ctx->in);
 
83
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
 
84
 
 
85
        /* Now fill the next block with 56 bytes */
 
86
        memset(ctx->in, 0, 56);
 
87
@@ -140,10 +140,10 @@ void MD5Final(unsigned char *digest, struct MD5Context *ctx)
 
88
     byteReverse(ctx->in, 14);
 
89
 
 
90
     /* Append length in bits and transform */
 
91
-    ((uint32 *) ctx->in)[14] = ctx->bits[0];
 
92
-    ((uint32 *) ctx->in)[15] = ctx->bits[1];
 
93
+    ((uint32_t *) ctx->in)[14] = ctx->bits[0];
 
94
+    ((uint32_t *) ctx->in)[15] = ctx->bits[1];
 
95
 
 
96
-    MD5Transform(ctx->buf, (uint32 *) ctx->in);
 
97
+    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
 
98
     byteReverse((unsigned char *) ctx->buf, 4);
 
99
     memcpy(digest, ctx->buf, 16);
 
100
     memset(ctx, 0, sizeof(ctx));       /* In case it's sensitive */
 
101
@@ -173,9 +173,9 @@ void MD5Final(unsigned char *digest, struct MD5Context *ctx)
 
102
  * reflect the addition of 16 longwords of new data.  MD5Update blocks
 
103
  * the data and converts bytes into longwords for this routine.
 
104
  */
 
105
-static void MD5Transform(uint32 buf[4], uint32 const in[16])
 
106
+static void MD5Transform(uint32_t buf[4], uint32_t const in[16])
 
107
 {
 
108
-    register uint32 a, b, c, d;
 
109
+    register uint32_t a, b, c, d;
 
110
 
 
111
     a = buf[0];
 
112
     b = buf[1];
 
113
diff --git a/src/md5.h b/src/md5.h
 
114
index 6d8d047..a8a952f 100644
 
115
--- a/src/md5.h
 
116
+++ b/src/md5.h
 
117
@@ -1,15 +1,11 @@
 
118
 #ifndef MD5_H
 
119
 #define MD5_H
 
120
 
 
121
-#ifdef __alpha
 
122
-typedef unsigned int uint32;
 
123
-#else
 
124
-typedef unsigned long uint32;
 
125
-#endif
 
126
+#include <stdint.h>
 
127
 
 
128
 struct MD5Context {
 
129
-       uint32 buf[4];
 
130
-       uint32 bits[2];
 
131
+       uint32_t buf[4];
 
132
+       uint32_t bits[2];
 
133
        unsigned char in[64];
 
134
 };
 
135
 
 
136
-- 
 
137
1.6.1
 
138