forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3ea7e95
committed
Avoid possible dangling-pointer access in tsearch_readline_callback.
tsearch_readline() saves the string pointer it returns to the callerfor possible use in the associated error context callback. However,the caller will usually pfree that string sometime before it nextcalls tsearch_readline(), so that there is a window where an ereportwill try to print an already-freed string.The built-in users of tsearch_readline() happen to all do that pfreeat the bottoms of their loops, so that the window is effectivelyempty for them. However, this is not documented as a requirement,and contrib/dict_xsyn doesn't do it like that, so it seems likelythat third-party dictionaries might have live bugs here.The practical consequences of this seem pretty limited in any case,since production builds wouldn't clobber the freed string immediately,besides which you'd not expect syntax errors in dictionary filesbeing used in production. Still, it's clearly a bug waiting to bitesomebody.Fix by pstrdup'ing the string to be saved for the error callback,and then pfree'ing it next time through. It's been like this fora long time, so back-patch to all supported branches.Discussion:https://postgr.es/m/48A4FA71-524E-41B9-953A-FD04EF36E2E7@yesql.se1 parent733fa9a commit3ea7e95
1 file changed
+29
-2
lines changedLines changed: 29 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
147 | 147 |
| |
148 | 148 |
| |
149 | 149 |
| |
| 150 | + | |
150 | 151 |
| |
151 |
| - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
152 | 161 |
| |
153 |
| - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
154 | 172 |
| |
155 | 173 |
| |
156 | 174 |
| |
| |||
160 | 178 |
| |
161 | 179 |
| |
162 | 180 |
| |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
163 | 189 |
| |
| 190 | + | |
164 | 191 |
| |
165 | 192 |
| |
166 | 193 |
| |
|
0 commit comments
Comments
(0)