![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The following bug has been logged online: Bug reference: 1270 Logged by: Peter Davie Email address: Peter.Davie (AT) relevance (DOT) com.au PostgreSQL version: 7.4.5 Operating system: OSF/1 4.0f Description: stack overflow in thread in fe_getauthname Details: With the THREAD_SAFETY changes, a buffer is defined on the stack as: char pwdbuf[BUFSIZ]; This buffer overflows the stack when used in a thread. As the application creating the thread cannot be modified to increase the stack size, it would probably be prudent to reduce this buffer size (I believe that BUFSIZ is around 8192 bytes on most modern Unix implementations). To rectify this issue (seg faults attempting to connect to the database), I replaced the above declaration with: char pwdbuf[1024]; Obviously, a manifest constant would be better! ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster |
#3
| |||
| |||
|
|
With the THREAD_SAFETY changes, a buffer is defined on the stack as: char pwdbuf[BUFSIZ]; This buffer overflows the stack when used in a thread. As the application creating the thread cannot be modified to increase the stack size, it would probably be prudent to reduce this buffer size (I believe that BUFSIZ is around 8192 bytes on most modern Unix implementations). |
#4
| |||
| |||
|
|
Oops. Yep, that is sloppy programming on our part, perhaps my part if I added those. Anyway, patch attached and applied. I used the proper struct sizes instead of BUFSIZ. |
|
This will be in 8.0. |
#5
| |||
| |||
|
|
"PostgreSQL Bugs List" <pgsql-bugs (AT) postgresql (DOT) org> writes: With the THREAD_SAFETY changes, a buffer is defined on the stack as: char pwdbuf[BUFSIZ]; This buffer overflows the stack when used in a thread. As the application creating the thread cannot be modified to increase the stack size, it would probably be prudent to reduce this buffer size (I believe that BUFSIZ is around 8192 bytes on most modern Unix implementations). No, it would be prudent to fix the app. While this one particular buffer might be larger than needed, we are *not* going to buy into the notion that libpq needs to run successfully in an 8K stack. This particular problem is only the tip of the iceberg; hewing to any such limit is going to require far more drastic changes that just don't seem worthwhile. |
#6
| |||
| |||
|
|
Bruce Momjian <pgman (AT) candle (DOT) pha.pa.us> writes: Oops. Yep, that is sloppy programming on our part, perhaps my part if I added those. Anyway, patch attached and applied. I used the proper struct sizes instead of BUFSIZ. You just broke it. Those buffers are not used to hold struct passwd's, but to hold multiple character strings to which the struct passwd will point; any one of which could be long, but particularly the home directory path. My man page for getpwuid_r says that the minimum recommended buffer size is 1024. This will be in 8.0. I think we should revert it entirely. A small buffer size risks breaking things unnecessarily, and as I replied earlier, the request to make libpq run in a less-than-8K stack is not reasonable anyway. |
![]() |
| Thread Tools | |
| Display Modes | |
| |