forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb83dcf7
committed
Add result size as argument of pg_cryptohash_final() for overflow checks
With its current design, a careless use of pg_cryptohash_final() couldwould result in an out-of-bound write in memory as the size of thedestination buffer to store the result digest is not known to thecryptohash internals, without the caller knowing about that. Thiscommit adds a new argument to pg_cryptohash_final() to allow such sanitychecks, and implements such defenses.The internals of SCRAM for HMAC could be tightened a bit more, but aseverything is based on SCRAM_KEY_LEN with uses particular to this codethere is no need to complicate its interface more than necessary, andthis comes back to the refactoring of HMAC in core. Except that, thisminimizes the uses of the existing DIGEST_LENGTH variables, relyinginstead on sizeof() for the result sizes. In ossp-uuid, this also makesthe code more defensive, as it already relied on dce_uuid_t being atleast the size of a MD5 digest.This is in philosophy similar tocfc40d3 for base64.c andaef8948 forhex.c.Reported-by: Ranier VilelaAuthor: Michael Paquier, Ranier VilelaReviewed-by: Kyotaro HoriguchiDiscussion:https://postgr.es/m/CAEudQAoqEGmcff3J4sTSV-R_16Monuz-UpJFbf_dnVH=APr02Q@mail.gmail.com1 parent2dd6733 commitb83dcf7
File tree
13 files changed
+82
-31
lines changed- contrib
- pgcrypto
- uuid-ossp
- src
- backend
- libpq
- replication
- utils/adt
- bin/pg_verifybackup
- common
- include/common
13 files changed
+82
-31
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
118 | 118 |
| |
119 | 119 |
| |
120 | 120 |
| |
121 |
| - | |
| 121 | + | |
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
109 |
| - | |
| 109 | + | |
110 | 110 |
| |
111 | 111 |
| |
112 | 112 |
| |
| |||
156 | 156 |
| |
157 | 157 |
| |
158 | 158 |
| |
159 |
| - | |
| 159 | + | |
160 | 160 |
| |
161 | 161 |
| |
162 | 162 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
324 | 324 |
| |
325 | 325 |
| |
326 | 326 |
| |
327 |
| - | |
| 327 | + | |
| 328 | + | |
328 | 329 |
| |
329 | 330 |
| |
330 | 331 |
| |
| |||
338 | 339 |
| |
339 | 340 |
| |
340 | 341 |
| |
341 |
| - | |
| 342 | + | |
342 | 343 |
| |
343 | 344 |
| |
344 | 345 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1429 | 1429 |
| |
1430 | 1430 |
| |
1431 | 1431 |
| |
1432 |
| - | |
| 1432 | + | |
1433 | 1433 |
| |
1434 | 1434 |
| |
1435 | 1435 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
330 | 330 |
| |
331 | 331 |
| |
332 | 332 |
| |
333 |
| - | |
| 333 | + | |
| 334 | + | |
334 | 335 |
| |
335 | 336 |
| |
336 |
| - | |
| 337 | + | |
337 | 338 |
| |
338 |
| - | |
| 339 | + | |
339 | 340 |
| |
340 | 341 |
| |
341 | 342 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
114 | 114 |
| |
115 | 115 |
| |
116 | 116 |
| |
117 |
| - | |
| 117 | + | |
| 118 | + | |
118 | 119 |
| |
119 | 120 |
| |
120 | 121 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
659 | 659 |
| |
660 | 660 |
| |
661 | 661 |
| |
662 |
| - | |
| 662 | + | |
| 663 | + | |
663 | 664 |
| |
664 | 665 |
| |
665 | 666 |
| |
|
Lines changed: 12 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
198 | 198 |
| |
199 | 199 |
| |
200 | 200 |
| |
201 |
| - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
202 | 204 |
| |
203 | 205 |
| |
204 |
| - | |
205 | 206 |
| |
206 | 207 |
| |
207 |
| - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
208 | 211 |
| |
209 | 212 |
| |
210 |
| - | |
211 | 213 |
| |
212 | 214 |
| |
213 |
| - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
214 | 218 |
| |
215 | 219 |
| |
216 |
| - | |
217 | 220 |
| |
218 | 221 |
| |
219 |
| - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
220 | 225 |
| |
221 | 226 |
| |
222 |
| - | |
223 | 227 |
| |
224 | 228 |
| |
225 | 229 |
| |
|
Lines changed: 16 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
160 | 160 |
| |
161 | 161 |
| |
162 | 162 |
| |
163 |
| - | |
164 |
| - | |
165 |
| - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
166 | 166 |
| |
167 | 167 |
| |
168 |
| - | |
| 168 | + | |
169 | 169 |
| |
170 | 170 |
| |
171 | 171 |
| |
172 | 172 |
| |
173 | 173 |
| |
174 | 174 |
| |
175 | 175 |
| |
| 176 | + | |
| 177 | + | |
176 | 178 |
| |
177 | 179 |
| |
178 | 180 |
| |
| 181 | + | |
| 182 | + | |
179 | 183 |
| |
180 | 184 |
| |
181 | 185 |
| |
| 186 | + | |
| 187 | + | |
182 | 188 |
| |
183 | 189 |
| |
184 | 190 |
| |
| 191 | + | |
| 192 | + | |
185 | 193 |
| |
186 | 194 |
| |
187 | 195 |
| |
| 196 | + | |
| 197 | + | |
188 | 198 |
| |
189 | 199 |
| |
190 | 200 |
| |
| 201 | + | |
| 202 | + | |
191 | 203 |
| |
192 | 204 |
| |
193 | 205 |
| |
|
Lines changed: 32 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 |
| |
28 | 31 |
| |
29 | 32 |
| |
| |||
181 | 184 |
| |
182 | 185 |
| |
183 | 186 |
| |
184 |
| - | |
| 187 | + | |
185 | 188 |
| |
186 | 189 |
| |
187 | 190 |
| |
188 | 191 |
| |
189 | 192 |
| |
190 | 193 |
| |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
191 | 222 |
| |
192 | 223 |
| |
193 | 224 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
81 |
| - | |
| 81 | + | |
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 |
| - | |
| 103 | + | |
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
54 |
| - | |
| 54 | + | |
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
| |||
112 | 112 |
| |
113 | 113 |
| |
114 | 114 |
| |
115 |
| - | |
| 115 | + | |
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
| |||
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
125 |
| - | |
| 125 | + | |
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
| |||
202 | 202 |
| |
203 | 203 |
| |
204 | 204 |
| |
205 |
| - | |
| 205 | + | |
206 | 206 |
| |
207 | 207 |
| |
208 | 208 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
35 |
| - | |
| 35 | + | |
36 | 36 |
| |
37 | 37 |
| |
38 | 38 |
|
0 commit comments
Comments
(0)