Repository navigation
Commit 6b2a8a1
committed
[BUG] Check what curl_slist_append and curl_multi_init return
Both are allocation points whose failure was treated as success, and both sit next
to a check the same file already makes.
curl_slist_append returns null without freeing the list it was given, and the docs
say so: "To avoid overwriting an existing non-empty list on failure, the new list
should be returned to a temporary variable which can be tested for NULL before
updating the original list pointer." Assigning straight back over headers_chunk did
the opposite. The pointer to everything appended so far went with it, so the two
places that free the list saw null and never ran, and Setup() only sets
CURLOPT_HTTPHEADER when headers_chunk is non-null, so the request went out with none
of the caller's headers rather than not going out. For an OTLP export that means no
Content-Type and a receiver that rejects a request the exporter believes it sent.
It now appends into a temporary. On failure the partial list is released, the
operation reports CreateFailed the same way it already does when curl_easy_init
returns null fifteen lines earlier, and nothing half built is left behind.
curl_multi_init returns null the same way, and its result went straight into
multi_handle_ in both constructors and in resetMultiHandle. Measured against libcurl
8.14.1, curl_multi_add_handle on a null multi handle reports CURLM_BAD_HANDLE, and
that return is discarded today, so such a client would accept every session, add
none of them, and complete none of them. The reset path is the worse of the three:
it runs while recovering from a multi error, so a failure there turns the client
into a black hole for the rest of its life. All three now go through one helper that
logs.
Fixes #4404
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>1 parent 04a8ddd commit 6b2a8a1
3 files changed
Lines changed: 36 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
270 | 271 | | |
271 | 272 | | |
272 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
273 | 286 | | |
274 | | - | |
| 287 | + | |
275 | 288 | | |
276 | 289 | | |
277 | 290 | | |
| |||
282 | 295 | | |
283 | 296 | | |
284 | 297 | | |
285 | | - | |
| 298 | + | |
286 | 299 | | |
287 | 300 | | |
288 | 301 | | |
| |||
909 | 922 | | |
910 | 923 | | |
911 | 924 | | |
912 | | - | |
| 925 | + | |
913 | 926 | | |
914 | 927 | | |
915 | 928 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
471 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
472 | 487 | | |
473 | 488 | | |
474 | 489 | | |
| |||
0 commit comments