From b1185ecc7370eaca1f416bd95914004219759940 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Thu, 25 May 2000 14:47:48 +0000 Subject: [PATCH] * vfs.c (mc_[un]def_getlocalcopy): better error handling on writing -------------------------------------------------------------- --- vfs/ChangeLog | 4 ++++ vfs/vfs.c | 19 ++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 12f4a86d0..39e4d4898 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,7 @@ +2000-05-23 Andrew V. Samoilov + + * vfs.c (mc_[un]def_getlocalcopy): better error handling on writing + 2000-05-18 Andrew V. Samoilov * ftpfs.c: (my_get_host_and_username) space between macro name and diff --git a/vfs/vfs.c b/vfs/vfs.c index d76e05ac1..a5f4d5343 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -1064,12 +1064,12 @@ mc_def_getlocalcopy (vfs *vfs, char *filename) fdout = open (tmp, O_CREAT|O_WRONLY|O_TRUNC|O_EXCL, 0600); if (fdout == -1) goto fail; - while ((i = mc_read (fdin, buffer, sizeof (buffer))) > 0) - write (fdout, buffer, i); + while ((i = mc_read (fdin, buffer, sizeof (buffer))) > 0){ + if (write (fdout, buffer, i) != i) + goto fail; + } if (i == -1) goto fail; - if (write (fdout, buffer, i)==-1) - goto fail; i = mc_close (fdin); fdin = -1; if (i==-1) @@ -1117,15 +1117,13 @@ mc_def_ungetlocalcopy (vfs *vfs, char *filename, char *local, int has_changed) fdout = mc_open (filename, O_WRONLY | O_TRUNC); if (fdout == -1) goto failed; - while ((i = read (fdin, buffer, sizeof (buffer))) == sizeof (buffer)){ - mc_write (fdout, buffer, i); - } + while ((i = read (fdin, buffer, sizeof (buffer))) > 0){ + if (mc_write (fdout, buffer, i) != i) + goto failed; + } if (i == -1) goto failed; - if (mc_write (fdout, buffer, i) == -1) - goto failed; - if (close (fdin)==-1) goto failed; if (mc_close (fdout)==-1) { @@ -1322,7 +1320,6 @@ vfs_split_text (char *p) char *original = p; int numcols; - for (numcols = 0; *p && numcols < MAXCOLS; numcols++){ while (*p == ' ' || *p == '\r' || *p == '\n'){ *p = 0;