forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf3f467b
committed
Avoid calling strerror[_r] in PQcancel().
PQcancel() is supposed to be safe to call from a signal handler,and indeed psql uses it that way. All of the library functionsit uses are specified to be async-signal-safe by POSIX ...except for strerror. Neither plain strerror nor strerror_rare considered safe. When this code was written, back in thedark ages, we probably figured "oh, strerror will just indexinto a constant array of strings" ... but in any locale except C,that's unlikely to be true. Probably the reason we've not heardcomplaints is that (a) this error-handling code is unlikely to bereached in normal use, and (b) in many scenarios, localized errorstrings would already have been loaded, after which maybe it'ssafe to call strerror here. Still, this is clearly unacceptable.The best we can do without relying on strerror is to print thedecimal value of errno, so make it do that instead. (This isprobably not much loss of user-friendliness, given that it ishard to get a failure here.)Back-patch to all supported branches.Discussion:https://postgr.es/m/2937814.1641960929@sss.pgh.pa.us1 parentcf92593 commitf3f467b
1 file changed
+19
-3
lines changedLines changed: 19 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4419 | 4419 |
| |
4420 | 4420 |
| |
4421 | 4421 |
| |
4422 |
| - | |
4423 | 4422 |
| |
4424 | 4423 |
| |
4425 | 4424 |
| |
| |||
4498 | 4497 |
| |
4499 | 4498 |
| |
4500 | 4499 |
| |
4501 |
| - | |
4502 |
| - | |
| 4500 | + | |
| 4501 | + | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
| 4506 | + | |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
4503 | 4519 |
| |
4504 | 4520 |
| |
4505 | 4521 |
| |
|
0 commit comments
Comments
(0)