On Wed, Jan 05, 2005 at 11:16:34AM -0000, Murray Elliot wrote:
> ERROR: buffer overflow in recv_exclude_list

It looks like some kind of corruption is going on over your ssh channel.
One way to investigate this would be to make a copy of the data that is
being sent and is being received.  I whipped up a C program to do this,
which I have attached to this message.

The program has a kluge in because it does not properly handle the EOF
condition when rsync is all done (I just made it timeout at 30 seconds
of inactivity and call it quits).  If you put the file cacheit.c into
your rsync directory (so it can use rsync.h and config.h), you can type
"make cacheit" and then put the resulting program into /tmp on each
system (or whereever else you like).  You should then be able to run
a command like this one:

rsync -av --rsh='/tmp/cacheit /tmp/rsync-sent ssh' [OPTIONS...]
    --rsync-path='/tmp/cacheit /tmp/rsync-got rsync' /from/ host:/to/

That will make a copy of the sent data in /tmp/rsync-sent on the sending
host, and a copy of the received data in /tmp/rsync-got on the receiving
host.  If the files are not identical, then there is a problem with your
transport/network.  If the files are identical (and rsync fails), feel
free to send me one of them.

..wayne..
#include "rsync.h"

int run_program(char **command);
char buf[4096];

int
main(int argc, char *argv[])
{
    int fd_file, fd_program, len;
    struct timeval tv;
    fd_set fds;

    if (argc < 4) {
	fprintf(stderr, "Usage: cacheit OUTPUT_FILE PROGRAM ARGS...\n");
	exit(1);
    }
    if ((fd_file = open(argv[1], O_WRONLY|O_TRUNC|O_CREAT|O_BINARY, 0644)) < 0) {
	fprintf(stderr, "Unable to write to `%s': %s\n", argv[1], strerror(errno));
	exit(1);
    }
#if HAVE_SETMODE && O_BINARY
    setmode(STDIN_FILENO, O_BINARY);
#endif
    set_blocking(STDIN_FILENO);
    set_nonblocking(STDIN_FILENO);

    fd_program = run_program(argv + 2);

    while (1) {
	FD_ZERO(&fds);
	FD_SET(STDIN_FILENO, &fds);
	tv.tv_sec = 30;
	tv.tv_usec = 0;
	if (!select(STDIN_FILENO+1, &fds, NULL, NULL, &tv))
	    break;
	if (!FD_ISSET(STDIN_FILENO, &fds))
	    break;
	if ((len = read(STDIN_FILENO, buf, sizeof buf)) <= 0)
	    break;
	if (write(fd_program, buf, len) != len) {
	    fprintf(stderr, "Unable to write to stdout.\n");
	    exit(1);
	}
	if (write(fd_file, buf, len) != len) {
	    fprintf(stderr, "Unable to write to stdout.\n");
	    exit(1);
	}
    }
    return 0;
}

int
run_program(char **command)
{
    int to_child_pipe[2];
    pid_t pid;

    if (pipe(to_child_pipe) < 0) {
	fprintf(stderr, "pipe failed: %s\n", strerror(errno));
	exit(1);
    }

    if ((pid = fork()) < 0) {
	fprintf(stderr, "fork failed: %s\n", strerror(errno));
	exit(1);
    }

    if (pid == 0) {
	if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 || close(to_child_pipe[1]) < 0) {
	    fprintf(stderr, "Failed to dup/close: %s\n", strerror(errno));
	    exit(1);
	}
	close(to_child_pipe[0]);
	set_blocking(STDIN_FILENO);
	set_blocking(STDOUT_FILENO);
	execvp(command[0], command);
	fprintf(stderr, "Failed to exec %s: %s\n", command[0], strerror(errno));
	exit(1);
    }

    if (close(to_child_pipe[0]) < 0 || close(STDOUT_FILENO) < 0 || close(STDERR_FILENO) < 0) {
	fprintf(stderr, "Failed to close: %s\n", strerror(errno));
	exit(1);
    }

    return to_child_pipe[1];
}

void
set_nonblocking(int fd)
{
    int val;

    if ((val = fcntl(fd, F_GETFL, 0)) == -1)
	return;
    if (!(val & NONBLOCK_FLAG)) {
	val |= NONBLOCK_FLAG;
	fcntl(fd, F_SETFL, val);
    }
}

void
set_blocking(int fd)
{
    int val;

    if ((val = fcntl(fd, F_GETFL, 0)) < 0)
	return;
    if (val & NONBLOCK_FLAG) {
	val &= ~NONBLOCK_FLAG;
	fcntl(fd, F_SETFL, val);
    }
}
-- 
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to