Commit 712c6ad
Git.pm: fix cat_blob crashes on large files
Read and write each 1024 byte buffer, rather than trying to buffer
the entire content of the file. We are only copying the contents to
a file descriptor and do not use it ourselves.
Previous code would crash on all files > 2 Gib, when the offset
variable became negative (perhaps below the level of perl),
resulting in a crash. On a 32 bit system, or a system with low
memory it might crash before reaching 2 GiB due to memory
exhaustion.
This code may leave a partial file behind in case of failure, where
the old code would leave a completely empty file. Neither version
verifies the correctness of the content. Calling code must take
care of verification and cleanup.
Signed-off-by: Joshua Clayton <[email protected]>
Reviewed-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 7e20105 commit 712c6ad
1 file changed
+7
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
| 893 | + | |
894 | 894 | | |
895 | 895 | | |
896 | | - | |
897 | 896 | | |
898 | 897 | | |
899 | 898 | | |
900 | | - | |
| 899 | + | |
901 | 900 | | |
902 | 901 | | |
903 | 902 | | |
904 | 903 | | |
905 | | - | |
906 | | - | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
907 | 909 | | |
908 | 910 | | |
909 | 911 | | |
| |||
918 | 920 | | |
919 | 921 | | |
920 | 922 | | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | 923 | | |
927 | 924 | | |
928 | 925 | | |
| |||
0 commit comments