* vfs/fish.c (fish_linear_start): Fix a hang when retrieving unreadable

file. Fixes savannah bug #21331.
This commit is contained in:
Pavel Tsekov 2007-10-26 13:46:42 +00:00
parent f5c8203418
commit 4a895496c7
2 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2007-10-26 Pavel Tsekov <ptsekov@gmx.net>
* fish.c (fish_linear_start): Fix a hang when retrieving unreadable
file. Fixes savannah bug #21331.
2007-10-11 Pavel Tsekov <ptsekov@gmx.net>
* fish.c (fish_linear_start): Use strtol() or strtoll() to retrieve

View File

@ -619,16 +619,28 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
g_free (name);
name = quoted_name;
fh->u.fish.append = 0;
/*
* Check whether the remote file is readable by using `dd' to copy
* a single byte from the remote file to /dev/null. If `dd' completes
* with exit status of 0 use `cat' to send the file contents to the
* standard output (i.e. over the network).
*/
offset = fish_command (me, FH_SUPER, WANT_STRING,
"#RETR /%s\n"
"if dd if=/%s of=/dev/null bs=1 count=1 2>/dev/null ;\n"
"then\n"
"ls -ln /%s 2>/dev/null | (\n"
"read p l u g s r\n"
"echo \"$s\"\n"
")\n"
"echo '### 100'\n"
"cat /%s\n"
"echo '### 200'\n",
name, name, name );
"echo '### 200'\n"
"else\n"
"echo '### 500'\n"
"fi\n",
name, name, name, name );
g_free (name);
if (offset != PRELIM) ERRNOR (E_REMOTE, 0);
fh->linear = LS_LINEAR_OPEN;