Artifactspublic-v0

curl

master
ply4 git calls32 ms289 KiB3 cachedprotocol v2
236 lines6.1 KiBRaw
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 "curl_setup.h"
26#ifdef HAVE_ARPA_INET_H
27#include <arpa/inet.h>
28#endif
30#include "urldata.h"
31#include "vtls/vtls.h"
32#include "curl_trc.h"
33#include "rand.h"
34#include "escape.h"
36#include "curlx/winapi.h"
38#ifndef USE_SSL
39/* ---- possibly non-cryptographic version following ---- */
40static CURLcode weak_random(struct Curl_easy *data,
41 unsigned char *entropy,
42 size_t length) /* always 4, size of int */
44 unsigned int r;
45 DEBUGASSERT(length == sizeof(int));
47 /* Trying cryptographically secure functions first */
48#ifdef _WIN32
49 (void)data;
50 {
51 CURLcode result = curlx_win32_random(entropy, length);
52 if(result != CURLE_NOT_BUILT_IN)
53 return result;
54 }
55#endif
57#ifdef HAVE_ARC4RANDOM
58 (void)data;
59 r = (unsigned int)arc4random();
60 memcpy(entropy, &r, length);
61#else
62 infof(data, "WARNING: using weak random seed");
63 {
64 static unsigned int randseed;
65 static bool seeded = FALSE;
66 unsigned int rnd;
67 if(!seeded) {
68 struct curltime now;
69 curlx_pnow(&now);
70 randseed += (unsigned int)now.tv_usec + (unsigned int)now.tv_sec;
71 randseed = randseed * 1103515245 + 12345;
72 randseed = randseed * 1103515245 + 12345;
73 randseed = randseed * 1103515245 + 12345;
74 seeded = TRUE;
75 }
77 /* Return an unsigned 32-bit pseudo-random number. */
78 r = randseed = randseed * 1103515245 + 12345;
79 rnd = (r << 16) | ((r >> 16) & 0xFFFF);
80 memcpy(entropy, &rnd, length);
81 }
82#endif
83 return CURLE_OK;
85#endif
87static CURLcode randit(struct Curl_easy *data, unsigned int *rnd,
88 bool env_override)
90#ifdef DEBUGBUILD
91 if(env_override) {
92 char *force_entropy = getenv("CURL_ENTROPY");
93 if(force_entropy) {
94 static unsigned int randseed;
95 static bool seeded = FALSE;
97 if(!seeded) {
98 unsigned int seed = 0;
99 size_t elen = strlen(force_entropy);
100 size_t clen = sizeof(seed);
101 size_t min = elen < clen ? elen : clen;
102 memcpy((char *)&seed, force_entropy, min);
103 randseed = ntohl(seed);
104 seeded = TRUE;
105 }
106 else
107 randseed++;
108 *rnd = randseed;
109 return CURLE_OK;
110 }
111 }
112#else
113 (void)env_override;
114#endif
116 /* data may be NULL! */
117#ifdef USE_SSL
118 return Curl_ssl_random(data, (unsigned char *)rnd, sizeof(*rnd));
119#else
120 return weak_random(data, (unsigned char *)rnd, sizeof(*rnd));
121#endif
124/*
125 * Curl_rand() stores 'num' number of random unsigned characters in the buffer
126 * 'rnd' points to.
127 *
128 * If libcurl is built without TLS support or arc4random, this function will
129 * use "weak" random.
130 *
131 * When built *with* TLS support, it will return error if it cannot provide
132 * strong random values.
133 *
134 * NOTE: 'data' may be passed in as NULL when coming from external API without
135 * easy handle!
136 *
137 */
139CURLcode Curl_rand_bytes(struct Curl_easy *data,
140#ifdef DEBUGBUILD
141 bool env_override,
142#endif
143 unsigned char *rnd, size_t num)
145 CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
146#ifndef DEBUGBUILD
147 const bool env_override = FALSE;
148#endif
150 DEBUGASSERT(num);
152#ifdef USE_SSL
153 /* get all bytes in one call unless they are forced for testing */
154 if(!env_override || !getenv("CURL_ENTROPY"))
155 return Curl_ssl_random(data, rnd, num);
156#endif
158 while(num) {
159 unsigned int r;
160 size_t left = num < sizeof(unsigned int) ? num : sizeof(unsigned int);
162 result = randit(data, &r, env_override);
163 if(result)
164 return result;
166 while(left) {
167 *rnd++ = (unsigned char)(r & 0xFF);
168 r >>= 8;
169 --num;
170 --left;
171 }
172 }
174 return result;
177/*
178 * Curl_rand_hex() fills the 'rnd' buffer with a given 'num' size with random
179 * hexadecimal digits PLUS a null-terminator byte. It must be an odd number
180 * size.
181 */
183CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num)
185 CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
186 unsigned char buffer[128];
187 DEBUGASSERT(num > 1);
189 if((num / 2 >= sizeof(buffer)) || !(num & 1)) {
190 /* make sure it fits in the local buffer and that it is an odd number! */
191 DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex"));
192 return CURLE_BAD_FUNCTION_ARGUMENT;
193 }
195 num--; /* save one for null-termination */
197 result = Curl_rand(data, buffer, num / 2);
198 if(result)
199 return result;
201 Curl_hexencode(buffer, num / 2, rnd, num + 1);
202 return result;
205/*
206 * Curl_rand_alnum() fills the 'rnd' buffer with a given 'num' size with random
207 * alphanumerical chars PLUS a null-terminator byte.
208 */
210static const char alnum[] =
211 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
213CURLcode Curl_rand_alnum(struct Curl_easy *data, unsigned char *rnd,
214 size_t num)
216 CURLcode result = CURLE_OK;
217 const unsigned int alnumspace = CURL_CSTRLEN(alnum);
218 unsigned int r;
219 DEBUGASSERT(num > 1);
221 num--; /* save one for null-termination */
223 while(num) {
224 do {
225 result = randit(data, &r, TRUE);
226 if(result)
227 return result;
228 } while(r >= (UINT_MAX - UINT_MAX % alnumspace));
230 *rnd++ = (unsigned char)alnum[r % alnumspace];
231 num--;
232 }
233 *rnd = 0;
235 return result;
Diagnostics4 git calls · 32 ms
CallStatusSizeTime032 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=3
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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=26
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
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=86
Open pack map
fetch2002.3 KiB · hit26 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2362
git.response.cache=HIT
git.response.duration_ms=26
git.fetch.wants=be0a2f11b9925cb8c18027e1aef8ffa04bd53679
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=2362
git.pkt.payload.max=2341
git.sideband.band1.bytes=2340
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
a5e184149aea3014
Request
e89f9ec1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format