forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit16e3ad5
committed
Avoid using %c printf format for potentially non-ASCII characters.
Since %c only passes a C "char" to printf, it's incapable of dealingwith multibyte characters. Passing just the first byte of such acharacter leads to an output string that is visibly not correctlyencoded, resulting in undesirable behavior such as encoding conversionfailures while sending error messages to clients.We've lived with this issue for a long time because it was inconvenientto avoid in a portable fashion. However, now that we always use our ownsnprintf code, it's reasonable to use the %.*s format to print just onepossibly-multibyte character in a string. (We previously avoided thatobvious-looking answer in order to work around glibc's bug #6530, cfcommits54cd4f0 anded437e2.)Hence, run around and fix a bunch of places that used %c to reporta character found in a user-supplied string. For simplicity, I didnot touch places that were emitting non-user-facing debug messages,or reporting catalog data that should always be ASCII. (It's alsounclear how useful this approach could be in frontend code, whereit's less certain that we know what encoding we're dealing with.)In passing, improve a couple of poorly-written error messages inpageinspect/heapfuncs.c.This is a longstanding issue, but I'm hesitant to back-patch becauseof the impact on translatable message strings. In any case this fixwould not work reliably before v12.Tom Lane and Quan ZongliangDiscussion:https://postgr.es/m/a120087c-4c88-d9d4-1ec5-808d7a7f133d@gmail.com1 parent78c8876 commit16e3ad5
File tree
7 files changed
+47
-32
lines changed- contrib
- hstore
- pageinspect
- src/backend/utils/adt
7 files changed
+47
-32
lines changedLines changed: 12 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
83 |
| - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
84 | 86 |
| |
85 | 87 |
| |
86 | 88 |
| |
| |||
219 | 221 |
| |
220 | 222 |
| |
221 | 223 |
| |
222 |
| - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
223 | 227 |
| |
224 | 228 |
| |
225 | 229 |
| |
| |||
234 | 238 |
| |
235 | 239 |
| |
236 | 240 |
| |
237 |
| - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
238 | 244 |
| |
239 | 245 |
| |
240 | 246 |
| |
| |||
267 | 273 |
| |
268 | 274 |
| |
269 | 275 |
| |
270 |
| - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
271 | 279 |
| |
272 | 280 |
| |
273 | 281 |
| |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
99 | 100 |
| |
100 | 101 |
| |
101 | 102 |
| |
102 |
| - | |
| 103 | + | |
| 104 | + | |
103 | 105 |
| |
104 | 106 |
| |
105 | 107 |
| |
| |||
460 | 462 |
| |
461 | 463 |
| |
462 | 464 |
| |
463 |
| - | |
464 |
| - | |
| 465 | + | |
465 | 466 |
| |
466 | 467 |
| |
467 | 468 |
| |
468 | 469 |
| |
469 | 470 |
| |
470 |
| - | |
| 471 | + | |
471 | 472 |
| |
472 | 473 |
| |
473 | 474 |
| |
| |||
478 | 479 |
| |
479 | 480 |
| |
480 | 481 |
| |
481 |
| - | |
| 482 | + | |
482 | 483 |
| |
483 | 484 |
| |
484 | 485 |
| |
|
Lines changed: 13 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
| |||
171 | 172 |
| |
172 | 173 |
| |
173 | 174 |
| |
174 |
| - | |
| 175 | + | |
175 | 176 |
| |
| 177 | + | |
176 | 178 |
| |
177 | 179 |
| |
178 |
| - | |
179 |
| - | |
| 180 | + | |
| 181 | + | |
180 | 182 |
| |
181 | 183 |
| |
182 | 184 |
| |
183 | 185 |
| |
184 |
| - | |
| 186 | + | |
| 187 | + | |
185 | 188 |
| |
186 | 189 |
| |
187 | 190 |
| |
| |||
205 | 208 |
| |
206 | 209 |
| |
207 | 210 |
| |
208 |
| - | |
| 211 | + | |
| 212 | + | |
209 | 213 |
| |
210 | 214 |
| |
211 | 215 |
| |
212 | 216 |
| |
213 | 217 |
| |
214 |
| - | |
| 218 | + | |
| 219 | + | |
215 | 220 |
| |
216 | 221 |
| |
217 | 222 |
| |
| |||
338 | 343 |
| |
339 | 344 |
| |
340 | 345 |
| |
341 |
| - | |
| 346 | + | |
| 347 | + | |
342 | 348 |
| |
343 | 349 |
| |
344 | 350 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
526 | 526 |
| |
527 | 527 |
| |
528 | 528 |
| |
529 |
| - | |
530 |
| - | |
| 529 | + | |
| 530 | + | |
531 | 531 |
| |
532 | 532 |
| |
533 | 533 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
423 | 423 |
| |
424 | 424 |
| |
425 | 425 |
| |
426 |
| - | |
427 |
| - | |
| 426 | + | |
| 427 | + | |
428 | 428 |
| |
429 | 429 |
| |
430 | 430 |
| |
|
Lines changed: 8 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
230 | 230 |
| |
231 | 231 |
| |
232 | 232 |
| |
233 |
| - | |
234 |
| - | |
| 233 | + | |
| 234 | + | |
235 | 235 |
| |
236 | 236 |
| |
237 | 237 |
| |
| |||
255 | 255 |
| |
256 | 256 |
| |
257 | 257 |
| |
258 |
| - | |
259 |
| - | |
| 258 | + | |
| 259 | + | |
260 | 260 |
| |
261 | 261 |
| |
262 | 262 |
| |
| |||
531 | 531 |
| |
532 | 532 |
| |
533 | 533 |
| |
534 |
| - | |
535 |
| - | |
| 534 | + | |
| 535 | + | |
536 | 536 |
| |
537 | 537 |
| |
538 | 538 |
| |
| |||
556 | 556 |
| |
557 | 557 |
| |
558 | 558 |
| |
559 |
| - | |
560 |
| - | |
| 559 | + | |
| 560 | + | |
561 | 561 |
| |
562 | 562 |
| |
563 | 563 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5586 | 5586 |
| |
5587 | 5587 |
| |
5588 | 5588 |
| |
5589 |
| - | |
5590 |
| - | |
| 5589 | + | |
| 5590 | + | |
5591 | 5591 |
| |
5592 | 5592 |
| |
5593 | 5593 |
| |
| |||
5707 | 5707 |
| |
5708 | 5708 |
| |
5709 | 5709 |
| |
5710 |
| - | |
5711 |
| - | |
| 5710 | + | |
| 5711 | + | |
5712 | 5712 |
| |
5713 | 5713 |
| |
5714 | 5714 |
| |
|
0 commit comments
Comments
(0)