Commit cbbe1a9
committed
crypto: fix use-after-free risk in ManagedX509 assignment
Fixes a potential double-free issue where ManagedX509::operator=
resets the underlying smart pointer using a raw pointer from another
instance before incrementing the reference count. If both instances
were managing the same underlying OpenSSL object, the reset could
decrement the reference count to 0 and free the object before the
reference count could be incremented.
This fixes Coverity issue 367349 where different smart pointers
were seemingly managing the same raw pointer.
Fixes: #569261 parent fc4b334 commit cbbe1a9
2 files changed
Lines changed: 26 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
133 | | - | |
134 | | - | |
135 | 131 | | |
136 | 132 | | |
137 | 133 | | |
| |||
144 | 140 | | |
145 | 141 | | |
146 | 142 | | |
147 | | - | |
| 143 | + | |
148 | 144 | | |
149 | 145 | | |
150 | 146 | | |
| |||
158 | 154 | | |
159 | 155 | | |
160 | 156 | | |
161 | | - | |
| 157 | + | |
162 | 158 | | |
163 | 159 | | |
164 | 160 | | |
| |||
349 | 345 | | |
350 | 346 | | |
351 | 347 | | |
352 | | - | |
| 348 | + | |
353 | 349 | | |
354 | 350 | | |
355 | 351 | | |
| |||
374 | 370 | | |
375 | 371 | | |
376 | 372 | | |
377 | | - | |
| 373 | + | |
378 | 374 | | |
379 | 375 | | |
380 | 376 | | |
| |||
407 | 403 | | |
408 | 404 | | |
409 | 405 | | |
410 | | - | |
| 406 | + | |
| 407 | + | |
411 | 408 | | |
412 | 409 | | |
413 | 410 | | |
| |||
424 | 421 | | |
425 | 422 | | |
426 | 423 | | |
427 | | - | |
| 424 | + | |
| 425 | + | |
428 | 426 | | |
429 | | - | |
| 427 | + | |
| 428 | + | |
430 | 429 | | |
431 | | - | |
| 430 | + | |
| 431 | + | |
432 | 432 | | |
433 | | - | |
| 433 | + | |
| 434 | + | |
434 | 435 | | |
435 | | - | |
| 436 | + | |
| 437 | + | |
436 | 438 | | |
437 | | - | |
| 439 | + | |
| 440 | + | |
438 | 441 | | |
439 | 442 | | |
440 | 443 | | |
| |||
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
449 | | - | |
| 452 | + | |
| 453 | + | |
450 | 454 | | |
451 | 455 | | |
452 | 456 | | |
| |||
0 commit comments