- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitc083095
committed
Make escaping functions retain trailing bytes of an invalid character.
Instead of dropping the trailing byte(s) of an invalid or incompletemultibyte character, replace only the first byte with a known-invalidsequence, and process the rest normally. This seems less likely toconfuse incautious callers than the behavior adopted in5dc1e42.While we're at it, adjust PQescapeStringInternal to produce at mostone bleat about invalid multibyte characters per string. Thismatches the behavior of PQescapeInternal, and avoids the risk ofproducing tons of repetitive junk if a long string is simply givenin the wrong encoding.This is a followup to the fixes forCVE-2025-1094, and should beincluded if cherry-picking those fixes.Author: Andres Freund <andres@anarazel.de>Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>Reported-by: Jeff Davis <pgsql@j-davis.com>Discussion:https://postgr.es/m/20250215012712.45@rfd.leadboat.comBackpatch-through: 131 parent985908d commitc083095
2 files changed
+67
-97
lines changedLines changed: 34 additions & 57 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
180 | 180 |
| |
181 | 181 |
| |
182 | 182 |
| |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 |
| - | |
187 |
| - | |
188 |
| - | |
189 |
| - | |
190 |
| - | |
191 |
| - | |
192 |
| - | |
193 |
| - | |
194 |
| - | |
195 |
| - | |
196 |
| - | |
197 |
| - | |
198 |
| - | |
199 |
| - | |
200 |
| - | |
201 |
| - | |
| 183 | + | |
| 184 | + | |
202 | 185 |
| |
203 | 186 |
| |
204 | 187 |
| |
205 |
| - | |
| 188 | + | |
206 | 189 |
| |
207 | 190 |
| |
208 | 191 |
| |
209 |
| - | |
210 |
| - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
211 | 196 |
| |
212 | 197 |
| |
213 | 198 |
| |
214 |
| - | |
215 |
| - | |
216 |
| - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
217 | 202 |
| |
218 | 203 |
| |
219 | 204 |
| |
| |||
222 | 207 |
| |
223 | 208 |
| |
224 | 209 |
| |
225 |
| - | |
226 |
| - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
227 | 214 |
| |
228 |
| - | |
229 |
| - | |
| 215 | + | |
| 216 | + | |
230 | 217 |
| |
231 | 218 |
| |
232 | 219 |
| |
| |||
395 | 382 |
| |
396 | 383 |
| |
397 | 384 |
| |
398 |
| - | |
399 |
| - | |
400 |
| - | |
401 |
| - | |
402 |
| - | |
403 |
| - | |
404 |
| - | |
405 |
| - | |
406 |
| - | |
407 |
| - | |
408 |
| - | |
409 |
| - | |
410 |
| - | |
411 |
| - | |
412 |
| - | |
413 |
| - | |
414 |
| - | |
415 |
| - | |
416 |
| - | |
| 385 | + | |
| 386 | + | |
417 | 387 |
| |
418 | 388 |
| |
419 | 389 |
| |
420 |
| - | |
| 390 | + | |
421 | 391 |
| |
422 | 392 |
| |
423 | 393 |
| |
424 |
| - | |
425 |
| - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
426 | 402 |
| |
427 | 403 |
| |
428 | 404 |
| |
429 |
| - | |
430 |
| - | |
| 405 | + | |
| 406 | + | |
431 | 407 |
| |
432 | 408 |
| |
433 | 409 |
| |
434 |
| - | |
435 | 410 |
| |
436 | 411 |
| |
437 |
| - | |
438 |
| - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
439 | 415 |
| |
440 |
| - | |
| 416 | + | |
| 417 | + | |
441 | 418 |
| |
442 | 419 |
| |
443 | 420 |
| |
|
Lines changed: 33 additions & 40 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3955 | 3955 |
| |
3956 | 3956 |
| |
3957 | 3957 |
| |
| 3958 | + | |
3958 | 3959 |
| |
3959 | 3960 |
| |
3960 | 3961 |
| |
| |||
3981 | 3982 |
| |
3982 | 3983 |
| |
3983 | 3984 |
| |
3984 |
| - | |
| 3985 | + | |
| 3986 | + | |
3985 | 3987 |
| |
3986 | 3988 |
| |
3987 |
| - | |
3988 |
| - | |
3989 |
| - | |
3990 |
| - | |
3991 |
| - | |
| 3989 | + | |
| 3990 | + | |
| 3991 | + | |
| 3992 | + | |
| 3993 | + | |
| 3994 | + | |
| 3995 | + | |
| 3996 | + | |
| 3997 | + | |
3992 | 3998 |
| |
3993 | 3999 |
| |
3994 |
| - | |
3995 |
| - | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
3996 | 4003 |
| |
3997 | 4004 |
| |
3998 | 4005 |
| |
3999 | 4006 |
| |
4000 | 4007 |
| |
4001 |
| - | |
4002 |
| - | |
4003 |
| - | |
4004 |
| - | |
4005 |
| - | |
4006 |
| - | |
4007 |
| - | |
4008 |
| - | |
4009 |
| - | |
4010 |
| - | |
4011 |
| - | |
4012 |
| - | |
4013 |
| - | |
4014 |
| - | |
4015 |
| - | |
4016 |
| - | |
4017 |
| - | |
4018 |
| - | |
4019 |
| - | |
4020 |
| - | |
4021 |
| - | |
4022 |
| - | |
4023 |
| - | |
4024 | 4008 |
| |
4025 | 4009 |
| |
4026 | 4010 |
| |
4027 |
| - | |
4028 |
| - | |
| 4011 | + | |
| 4012 | + | |
4029 | 4013 |
| |
4030 | 4014 |
| |
4031 | 4015 |
| |
4032 |
| - | |
4033 |
| - | |
4034 |
| - | |
| 4016 | + | |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
4035 | 4027 |
| |
4036 | 4028 |
| |
4037 | 4029 |
| |
4038 |
| - | |
4039 | 4030 |
| |
4040 | 4031 |
| |
4041 |
| - | |
4042 |
| - | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
4043 | 4035 |
| |
4044 |
| - | |
| 4036 | + | |
| 4037 | + | |
4045 | 4038 |
| |
4046 | 4039 |
| |
4047 | 4040 |
| |
|
0 commit comments
Comments
(0)