mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
fsp: Fixed a serious bug.
*fresult pointed to nowhere. On FreeBSD *fresult == NULL
and directories weren't displayed.
Check also if safe_write writes all data.
(cherry picked from commit 06bcc48487
)
This commit is contained in:
parent
1ab670cfce
commit
8a02678bed
@ -171,7 +171,8 @@ display_entry(const FSP_RDENTRY *fentry, const unsigned char dircolor[])
|
|||||||
static void
|
static void
|
||||||
sort_and_display_entries(FSP_DIR *dir, const unsigned char dircolor[])
|
sort_and_display_entries(FSP_DIR *dir, const unsigned char dircolor[])
|
||||||
{
|
{
|
||||||
FSP_RDENTRY fentry, *fresult, *table = NULL;
|
FSP_RDENTRY fentry, tmp, *table = NULL;
|
||||||
|
FSP_RDENTRY *fresult = &tmp;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -228,7 +229,8 @@ fsp_directory(FSP_SESSION *ses, struct uri *uri)
|
|||||||
if (get_opt_bool("protocol.fsp.sort")) {
|
if (get_opt_bool("protocol.fsp.sort")) {
|
||||||
sort_and_display_entries(dir, dircolor);
|
sort_and_display_entries(dir, dircolor);
|
||||||
} else {
|
} else {
|
||||||
FSP_RDENTRY fentry, *fresult;
|
FSP_RDENTRY fentry, tmp;
|
||||||
|
FSP_RDENTRY *fresult = &tmp;
|
||||||
|
|
||||||
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
|
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
|
||||||
if (!fresult) break;
|
if (!fresult) break;
|
||||||
@ -318,10 +320,18 @@ do_fsp(struct connection *conn)
|
|||||||
(off_print_T) sb.st_size);
|
(off_print_T) sb.st_size);
|
||||||
fclose(stderr);
|
fclose(stderr);
|
||||||
|
|
||||||
while ((r = fsp_fread(buf, 1, READ_SIZE, file)) > 0)
|
while ((r = fsp_fread(buf, 1, READ_SIZE, file)) > 0) {
|
||||||
if (safe_write(STDOUT_FILENO, buf, r) <= 0)
|
int off = 0;
|
||||||
break;
|
|
||||||
|
|
||||||
|
while (r) {
|
||||||
|
int w = safe_write(STDOUT_FILENO, buf + off, r);
|
||||||
|
|
||||||
|
if (w == -1) goto out;
|
||||||
|
off += w;
|
||||||
|
r -= w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out:
|
||||||
fsp_fclose(file);
|
fsp_fclose(file);
|
||||||
fsp_close_session(ses);
|
fsp_close_session(ses);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user