master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
26#if !defined(CURL_DISABLE_MIME) && !defined(CURL_DISABLE_HTTP)
27static int callback_free_count = 0;
29static void test_cb_free(void *ptr)
30{
31 (void)ptr;
32 callback_free_count++;
33}
35static size_t test_cb_read(char *buffer, size_t size, size_t nitems, void *arg)
36{
37 (void)buffer;
38 (void)size;
39 (void)nitems;
40 (void)arg;
41 return 0;
42}
43#endif
45static CURLcode test_lib3596(const char *arg)
46{
47 UNITTEST_BEGIN_SIMPLE
49#if !defined(CURL_DISABLE_MIME) && !defined(CURL_DISABLE_HTTP)
51 CURL *curl = NULL;
52 CURLcode result = CURLE_OK;
53 curl_mime *root = NULL;
54 curl_mime *current = NULL;
55 curl_mime *sub = NULL;
56 curl_mimepart *part = NULL;
57 int i;
59 callback_free_count = 0;
61 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
62 curl_mfprintf(stderr, "curl_global_init() failed\n");
63 return TEST_ERR_MAJOR_BAD;
64 }
66 curl = curl_easy_init();
67 fail_unless(curl != NULL, "curl_easy_init() failed");
69 /* Create a deeper than MAX_MIME_LEVELS nested mime structure to verify
70 that header preparation bounds recursion instead of exhausting the
71 stack. */
72 root = curl_mime_init(curl);
73 fail_unless(root != NULL, "curl_mime_init root failed");
75 /* Add a sibling part with a custom free callback before the deep chain
76 to verify that preflight depth rejection does not duplicate callbacks
77 or invoke them during error rollback. */
78 part = curl_mime_addpart(root);
79 fail_unless(part != NULL, "curl_mime_addpart sibling failed");
80 result = curl_mime_data_cb(part, 0, test_cb_read, NULL, test_cb_free, NULL);
81 fail_unless(result == CURLE_OK, "curl_mime_data_cb failed");
83 current = root;
85 for(i = 0; i < 50; i++) {
86 part = curl_mime_addpart(current);
87 fail_unless(part != NULL, "curl_mime_addpart failed");
88 sub = curl_mime_init(curl);
89 fail_unless(sub != NULL, "curl_mime_init sub failed");
90 curl_mime_subparts(part, sub);
91 current = sub;
92 }
94 result = curl_easy_setopt(curl, CURLOPT_URL, arg);
95 fail_unless(result == CURLE_OK, "CURLOPT_URL failed");
96 if(!result)
97 result = curl_easy_setopt(curl, CURLOPT_MIMEPOST, root);
98 fail_unless(result == CURLE_OK, "CURLOPT_MIMEPOST failed");
100 /* Deep nesting must fail gracefully (CURLE_TOO_LARGE), not crash, and
101 must not invoke copied user free callbacks during error rollback. */
102 if(!result) {
103 CURL *dup = curl_easy_duphandle(curl);
104 fail_unless(dup == NULL,
105 "curl_easy_duphandle unexpectedly succeeded for nested mime");
106 fail_unless(callback_free_count == 0,
107 "free callback invoked during failed duphandle rollback");
108 }
110 if(!result)
111 result = curl_easy_perform(curl);
112 fail_unless(result == CURLE_TOO_LARGE,
113 "deeply nested mime did not fail with CURLE_TOO_LARGE");
115 {
116 CURL *dup = curl_easy_duphandle(curl);
117 fail_unless(dup == NULL,
118 "curl_easy_duphandle unexpectedly succeeded after perform");
119 fail_unless(callback_free_count == 0,
120 "free callback invoked after perform duphandle");
121 }
123 curl_easy_cleanup(curl);
124 curl_mime_free(root);
125 fail_unless(callback_free_count == 1,
126 "free callback not invoked during root cleanup");
127 curl_global_cleanup();
128#else
129 (void)arg;
130#endif
132 UNITTEST_END_SIMPLE
133}
Diagnostics4 git calls · 220 ms
CallStatusSizeTime0220 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=1 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=215 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2001.6 KiB215 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1607 git.response.cache=MISS git.response.duration_ms=215 git.fetch.wants=61b8f65f6d02fa010ff7bbc963f205df6492c36b git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1607 git.pkt.payload.max=1586 git.sideband.band1.bytes=1585 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e326640ea198f1
- Request
- 41034e19…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format