(fish_file_store): type accuracy to avoid counter overflow while copiyng huge files.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-10-29 09:59:09 +04:00
parent b968fe0df8
commit 2476f281de
1 changed files with 13 additions and 11 deletions

View File

@ -852,10 +852,11 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
fish_fh_data_t *fish = (fish_fh_data_t *) fh->data;
gchar *shell_commands = NULL;
struct vfs_s_super *super = FH_SUPER;
int n, total;
char buffer[8192];
int code;
off_t total;
char buffer[BUF_8K];
struct stat s;
int was_error = 0;
gboolean was_error = FALSE;
int h;
char *quoted_name;
@ -907,8 +908,8 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
g_strconcat (SUP->scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX ";\n",
SUP->scr_append, (char *) NULL);
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
code = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
g_free (shell_commands);
}
else
@ -916,11 +917,11 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
shell_commands =
g_strconcat (SUP->scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%" PRIuMAX ";\n",
SUP->scr_send, (char *) NULL);
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
code = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name,
(uintmax_t) s.st_size);
g_free (shell_commands);
}
if (n != PRELIM)
if (code != PRELIM)
{
close (h);
ERRNOR (E_REMOTE, -1);
@ -930,7 +931,8 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
while (TRUE)
{
int t;
ssize_t n, t;
while ((n = read (h, buffer, sizeof (buffer))) < 0)
{
if ((errno == EINTR) && tty_got_interrupt ())
@ -954,9 +956,9 @@ fish_file_store (struct vfs_class *me, vfs_file_handler_t * fh, char *name, char
}
tty_disable_interrupt_key ();
total += n;
vfs_print_message ("%s: %d/%" PRIuMAX,
vfs_print_message ("%s: %" PRIuMAX "/%" PRIuMAX,
was_error ? _("fish: storing zeros") : _("fish: storing file"),
total, (uintmax_t) s.st_size);
(uintmax_t) total, (uintmax_t) s.st_size);
}
close (h);
g_free (quoted_name);