Bug 5235 - buffer overflow in receive_file_entry
Summary: buffer overflow in receive_file_entry
Status: RESOLVED WONTFIX
Alias: None
Product: rsync
Classification: Unclassified
Component: core (show other bugs)
Version: 2.6.9
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Wayne Davison
QA Contact: Rsync QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-31 04:53 UTC by Daniel Platt
Modified: 2008-02-05 21:08 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Platt 2008-01-31 04:53:41 UTC
ERROR: buffer overflow in receive_file_entry
rsync error: error allocating core memory buffers (code 22) at util.c(126)

I also found a similiar error using google.com here..
http://lists.samba.org/archive/rsync/2005-April/012104.html

I have tested 2.6.6 and 2.6.8

This fix is for 2.6.8
The changes I have made to fix my error were in 

flist.c (489.c)

static struct file_struct *receive_file_entry(struct file_list *flist, unsigned
short flags, int f)

I changed the following lines:

        static char lastname[MAXPATHLEN], *lastdir;
        char thisname[MAXPATHLEN];

        if (l2 >= MAXPATHLEN - l1) {

to:

        static char lastname[BIGPATHBUFLEN], *lastdir;
        char thisname[BIGPATHBUFLEN];

        if (l2 >= BIGPATHBUFLEN - l1) {


I haven't done full debugged this, but it compiles and runs, and does what I
want so far.


The cause for this, was very long file names.
Comment 1 Wayne Davison 2008-02-05 21:08:52 UTC
The MAXPATHLEN value is supposed to be the maximum length of a string that the file-handling functions of your OS can accept.  If your OS (or maybe cygwin?) has it set too small, you should tell those responsible to make it larger.

In the meantime, you can also redefine MAXPATHLEN in config.h so that the whole app benefits (use #undef before the #define).  Making some buffers use BIGPATHBUFLEN instead of MAXPATHLEN can cause problems.