Control: tags -1 + patch

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,
наб
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 patch (2.7.6-7) unstable; urgency=medium
 .
   * Backport upstream fixes:
     - avoid invalid memory access in context format diffs,
     - fix failed assertion 'outstate->after_newline'.
   * Update packaging bits.
   * Update Standards-Version to 4.5.1 .
Author: Laszlo Boszormenyi (GCS) <g...@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2023-07-31

--- patch-2.7.6.orig/src/pch.c
+++ patch-2.7.6/src/pch.c
@@ -149,7 +149,7 @@ open_patch_file (char const *filename)
        if (! pfp)
          pfatal ("Can't open stream for file %s", quotearg (TMPPATNAME));
        for (st.st_size = 0;
-            (charsread = fread (buf, 1, bufsize, read_pfp)) != 0;
+            !feof(read_pfp) && (charsread = fread (buf, 1, bufsize, read_pfp)) 
!= 0;
             st.st_size += charsread)
          if (fwrite (buf, 1, charsread, pfp) != charsread)
            write_fatal ();

Attachment: signature.asc
Description: PGP signature

Reply via email to