From 05e1d830742a916dd8ab4a214802067005b61bac Mon Sep 17 00:00:00 2001 From: didg Date: Fri, 16 Oct 2009 00:48:08 +0000 Subject: [PATCH] copy_file if EINTR, cc -= write(...) was corrupting the buffer the size --- libatalk/vfs/unix.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libatalk/vfs/unix.c b/libatalk/vfs/unix.c index eaf25686..1760c645 100644 --- a/libatalk/vfs/unix.c +++ b/libatalk/vfs/unix.c @@ -1,5 +1,5 @@ /* - * $Id: unix.c,v 1.3 2009-10-16 00:40:48 didg Exp $ + * $Id: unix.c,v 1.4 2009-10-16 00:48:08 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -161,6 +161,7 @@ int copy_file(const char *src, const char *dst, mode_t mode) int sfd = -1; int dfd = -1; ssize_t cc; + size_t buflen; char filebuf[8192]; if ((sfd = open(src, O_RDONLY)) < 0) { @@ -186,8 +187,9 @@ int copy_file(const char *src, const char *dst, mode_t mode) goto exit; } - while (cc > 0) { - if ((cc -= write(dfd, filebuf, cc)) < 0) { + buflen = cc; + while (buflen > 0) { + if ((cc = write(dfd, filebuf, buflen)) < 0) { if (errno == EINTR) continue; LOG(log_error, logtype_afpd, "copy_file('%s'/'%s'): read '%s' error: %s", @@ -195,6 +197,7 @@ int copy_file(const char *src, const char *dst, mode_t mode) ret = -1; goto exit; } + buflen -= cc; } } -- 2.39.2