bugGNU patch - Bugs: bug #45990, out of bounds read with malformed...

 
 

bug #45990: out of bounds read with malformed patch in pch_write_line

Submitted by:  Hanno Boeck <hanno>
Submitted on:  Thu 17 Sep 2015 05:14:13 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 09 Aug 2016 10:14:58 PM UTC, comment #2:

Applied, thanks.

Andreas Gruenbacher <agruen>
Project Administrator
Tue 09 Aug 2016 07:13:13 AM UTC, comment #1:

I'm attaching a patch to fix this.

What happens is that there's an attempt to access
p_line[line][p_len[line] - 1]
in the function pch_write_line().

However in case p_len[line] is zero this will lead to an array access with offset -1, which is obviously invalid. The patch will add a check whether p_len[line] is larger than zero.

Please apply.

(file #38154)

Hanno Boeck <hanno>
Thu 17 Sep 2015 05:14:13 PM UTC, original submission:

The attached file will cause an out of bounds read in patch. Can be seen with address sanitizer or valgrind.

This was found with american fuzzy lop. I have already reported this privately to the gnu patch developers many months ago, but never got a reply.

Address Sanitizer stack trace:
==6761==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000ef6f at pc 0x000000501d1b bp 0x7ffebdd66310 sp 0x7ffebdd66308
READ of size 1 at 0x60200000ef6f thread T0
#0 0x501d1a in pch_write_line /tmp/patch/src/pch.c:2279:24
#1 0x4e520f in abort_hunk_unified /tmp/patch/src/patch.c:1301:4
#2 0x4e520f in abort_hunk /tmp/patch/src/patch.c:1395
#3 0x4e520f in main /tmp/patch/src/patch.c:471
#4 0x7fe379f467af in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.21-r1/work/glibc-2.21/csu/libc-start.c:289
#5 0x419558 in _start (/tmp/patch/src/patch+0x419558)

0x60200000ef6f is located 1 bytes to the left of 1-byte region [0x60200000ef70,0x60200000ef71)
allocated by thread T0 here:
#0 0x4af7f8 in __interceptor_malloc (/tmp/patch/src/patch+0x4af7f8)
#1 0x5141bf in savebuf /tmp/patch/src/util.c:861:8
#2 0x4e273d in main /tmp/patch/src/patch.c:390:25
#3 0x7fe379f467af in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.21-r1/work/glibc-2.21/csu/libc-start.c:289

Hanno Boeck <hanno>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #38154:  patch-fix-heap-oob.patch added by hanno (455B - text/x-patch - Patch to fix heap oob)
file #34911:  patch-heapoverflow-pch_write_line.diff added by hanno (20B - text/x-patch - fuzzed patch causing oob)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by agruen (Posted a comment)
  • -unavailable- added by hanno (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 09 Aug 2016 10:14:58 PM UTCagruenStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 09 Aug 2016 07:13:13 AM UTChannoAttached File-=>Added patch-fix-heap-oob.patch, #38154
    Thu 17 Sep 2015 05:14:13 PM UTChannoAttached File-=>Added patch-heapoverflow-pch_write_line.diff, #34911

    Back to the top


    Powered by Savane 3.1-cleanup1