* We want to be able to compare mmapped reference records quickly, * without totally parsing them. We can do so because the records are * LF-terminated, and the refname should start exactly (GIT_SHA1_HEXSZ * + 1) bytes past the beginning of the record. * * But what if the `packed-refs` file contains garbage? We're willing * to tolerate not detecting the problem, as long as we don't produce
| 490 | * these checks fails. |
| 491 | */ |
| 492 | static void verify_buffer_safe(struct snapshot *snapshot) |
| 493 | { |
| 494 | const char *start = snapshot->start; |
| 495 | const char *eof = snapshot->eof; |
| 496 | const char *last_line; |
| 497 | |
| 498 | if (start == eof) |
| 499 | return; |
| 500 | |
| 501 | last_line = find_start_of_record(start, eof - 1); |
| 502 | if (*(eof - 1) != '\n' || |
| 503 | eof - last_line < snapshot_hexsz(snapshot) + 2) |
| 504 | die_invalid_line(snapshot->refs->path, |
| 505 | last_line, eof - last_line); |
| 506 | } |
| 507 | |
| 508 | /* |
| 509 | * When parsing the "packed-refs" file, we will parse it line by line. |
no test coverage detected