MCPcopy Create free account
hub / github.com/RsyncProject/rsync / simple_recv_token

Function simple_recv_token

token.c:282–311  ·  view source on GitHub ↗

non-compressing recv token */

Source from the content-addressed store, hash-verified

280
281/* non-compressing recv token */
282static int32 simple_recv_token(int f, char **data)
283{
284 static int32 residue;
285 static char *buf;
286 int32 n;
287
288 if (!buf)
289 buf = new_array(char, CHUNK_SIZE);
290
291 if (residue == 0) {
292 int32 i = read_int(f);
293 if (i <= 0)
294 return i;
295 /* simple_send_token caps each literal chunk at CHUNK_SIZE;
296 * reject anything larger so a hostile peer cannot drive the
297 * read_buf below past our static CHUNK_SIZE buffer. */
298 if (i > CHUNK_SIZE) {
299 rprintf(FERROR, "invalid uncompressed token length %ld [%s]\n",
300 (long)i, who_am_i());
301 exit_cleanup(RERR_PROTOCOL);
302 }
303 residue = i;
304 }
305
306 *data = buf;
307 n = MIN(CHUNK_SIZE,residue);
308 residue -= n;
309 read_buf(f,buf,n);
310 return n;
311}
312
313/* non-compressing send token */
314static void simple_send_token(int f, int32 token, struct map_struct *buf, OFF_T offset, int32 n)

Callers 1

recv_tokenFunction · 0.85

Calls 4

read_intFunction · 0.85
rprintfFunction · 0.70
who_am_iFunction · 0.70
read_bufFunction · 0.70

Tested by

no test coverage detected