Bug 270081 - ktorrent segfaults due to p.getLength() returning 0x10000 (max value should be 0x4000)
Summary: ktorrent segfaults due to p.getLength() returning 0x10000 (max value should b...
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-04 15:18 UTC by Rick
Modified: 2011-04-05 19:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
logs, GDB dump and modified source so you can make sense of the logs (30.41 KB, text/plain)
2011-04-04 15:18 UTC, Rick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rick 2011-04-04 15:18:55 UTC
Created attachment 58563 [details]
logs, GDB dump and modified source so you can make sense of the logs

Version:           unspecified (using KDE 4.5.5) 
OS:                Linux

Program received signal SIGSEGV, Segmentation fault.
0x41d07594 in memcpy () from /lib/libc.so.6

caused by p.getLength in "bool ChunkDownload::piece(const Piece & p,bool & ok)" returning the value 0x10000.  This causes the memcpy() in the method to run off the end of DST buffer (which is only 0x4000 long) and it segfaults. 

I am running ARM Slackware current (KDE 4.5.5) on a SheevaPlug computer.  This fault happens every couple of days.  I will attach logs and stuff.  Unfortunately, tracebacks don't work in memcpy() because it's written in ASM and doesn't retain a proper stack frame.

Reproducible: Always
Comment 1 Joris Guisson 2011-04-04 18:57:08 UTC

*** This bug has been marked as a duplicate of bug 268162 ***
Comment 2 Rick 2011-04-04 23:19:02 UTC
I submitted 268162 and this is not the same bug!  

In 268162 the segfault was on the read of the SRC pointer to memcpy().  The SRC buffer is only a few bytes long and we try to read 0x4000 bytes from it.

In this one, the segfault is on the write of the DST pointer to memcpy().  Here the DST buffer is 0x4000 bytes long and we try to write 0x10000 bytes to it.  

And 268162 happens at least twenty times as often as this one.
Comment 3 Rick 2011-04-04 23:20:53 UTC
I submitted 268162 and this is not the same bug!  

In 268162 the segfault was on the read of the SRC pointer to memcpy().  The SRC buffer is only a few bytes long and we try to read 0x4000 bytes from it.

In this one, the segfault is on the write of the DST pointer to memcpy().  Here the DST buffer is 0x4000 bytes long and we try to write 0x10000 bytes to it.  

And 268162 happens at least twenty times as often as this one.
Comment 4 Joris Guisson 2011-04-05 19:19:46 UTC
The fix done for 268162, will also fix this situation. If the length of the Piece object does not match the length we expect, it will be ignored. 

You should upgrade to libktorrent 1.1