non-compressing recv token */
| 280 | |
| 281 | /* non-compressing recv token */ |
| 282 | static 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 */ |
| 314 | static void simple_send_token(int f, int32 token, struct map_struct *buf, OFF_T offset, int32 n) |
no test coverage detected