| 400 | #define MAX_APPLY_SIZE (1024UL * 1024 * 1023) |
| 401 | |
| 402 | static int read_patch_file(struct strbuf *sb, int fd) |
| 403 | { |
| 404 | if (strbuf_read(sb, fd, 0) < 0) |
| 405 | return error_errno(_("failed to read patch")); |
| 406 | else if (sb->len >= MAX_APPLY_SIZE) |
| 407 | return error(_("patch too large")); |
| 408 | /* |
| 409 | * Make sure that we have some slop in the buffer |
| 410 | * so that we can do speculative "memcmp" etc, and |
| 411 | * see to it that it is NUL-filled. |
| 412 | */ |
| 413 | strbuf_grow(sb, SLOP); |
| 414 | memset(sb->buf + sb->len, 0, SLOP); |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | static unsigned long linelen(const char *buffer, unsigned long size) |
| 419 | { |
no test coverage detected