Trivially found with
(gdb) bt
#0 0x00007ffff7ec807d in __GI___libc_read (fd=0, buf=0x5555555862a0, nbytes=8192) at ../sysdeps/unix/sysv/linux/read.c:26
#1 0x00007ffff7e51130 in __GI__IO_file_xsgetn (fp=0x7ffff7fa2a80 <_IO_2_1_stdin_>, data=<optimized out>, n=8192) at ./libio/libioP.h:947
#2 0x00007ffff7e46625 in __GI__IO_fread (buf=0x5555555862a0, size=size@entry=1, count=8192, fp=fp@entry=0x7ffff7fa2a80 <_IO_2_1_stdin_>) at ./libio/iofread.c:38
#3 0x000055555555e2ec in fread (__stream=<optimized out>, __n=<optimized out>, __size=1, __ptr=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:297
#4 open_patch_file (filename=<optimized out>) at pch.c:152
#5 0x0000555555558bcf in main (argc=<optimized out>, argv=<optimized out>) at patch.c:195
│ 151 for (st.st_size = 0;
│ > 152 (charsread = fread (buf, 1, bufsize, read_pfp)) != 0;
│ 153 st.st_size += charsread)
│ 154 if (fwrite (buf, 1, charsread, pfp) != charsread)
│ 155 write_fatal ();
which needs to check for !feof && (charsread = ....
Attaching patch against 2.7.6-7, validated it works.
Best,
наб