Commit 1872243
Fix #40: Prevent segfault from NULL via_p1 in transaction matching
Add comprehensive NULL checks to prevent segmentation faults when
matching SIP transactions with corrupted or invalid state:
1. compare_branch(): Check t, t->msg, and t->msg->via_p1 before access
2. match_reply(): Add NULL check for stored transaction's msg and via_p1
The crash occurred when iterating through stored transactions and
attempting to match branch parameters. While the incoming message's
via_p1 is validated by assertion, stored transactions could have NULL
via_p1 due to memory corruption, parser edge cases, or race conditions.
Changes from original fix:
- Also protect match_reply() which had the same vulnerability
- Check t->msg before t->msg->via_p1 to prevent cascading NULL deref
- Use ERROR instead of WARN (indicates serious bug condition)
- Add diagnostic pointer values to log message
Fixes: #401 parent 6e113db commit 1872243
1 file changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| |||
287 | 294 | | |
288 | 295 | | |
289 | 296 | | |
290 | | - | |
| 297 | + | |
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
294 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
295 | 308 | | |
296 | 309 | | |
297 | 310 | | |
| |||
0 commit comments