mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
int_min instead of int_max. Valgrind said: invalid read
copiousoutput III. It works only for local files, but you must remove | /usr/bin/less yourself and allow reading special files, and set default mime type as text/plain for convenience.
This commit is contained in:
parent
f6115e65ec
commit
a2c12d7653
@ -31,6 +31,7 @@
|
||||
#include "dialogs/menu.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/object.h"
|
||||
#include "main/select.h"
|
||||
#include "mime/mime.h"
|
||||
#include "network/connection.h"
|
||||
#include "network/progress.h"
|
||||
@ -973,6 +974,24 @@ tp_display(struct type_query *type_query)
|
||||
done_type_query(type_query);
|
||||
}
|
||||
|
||||
static void
|
||||
read_from_popen(struct type_query *type_query, unsigned char *handler)
|
||||
{
|
||||
FILE *pop = popen(handler, "r");
|
||||
|
||||
if (pop) {
|
||||
int fd = fileno(pop);
|
||||
|
||||
if (fd > 0) {
|
||||
struct session *ses = type_query->ses;
|
||||
unsigned char buf[48];
|
||||
|
||||
snprintf(buf, 48, "file:///dev/fd/%d", fd);
|
||||
goto_url(ses, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tp_open(struct type_query *type_query)
|
||||
{
|
||||
@ -991,6 +1010,9 @@ tp_open(struct type_query *type_query)
|
||||
}
|
||||
|
||||
if (handler) {
|
||||
if (type_query->copiousoutput)
|
||||
read_from_popen(type_query, handler);
|
||||
else
|
||||
exec_on_terminal(type_query->ses->tab->term,
|
||||
handler, "", !!type_query->block);
|
||||
mem_free(handler);
|
||||
@ -1078,7 +1100,7 @@ do_type_query(struct type_query *type_query, unsigned char *ct, struct mime_hand
|
||||
if (handler && handler->program) {
|
||||
int programlen = strlen(handler->program);
|
||||
|
||||
programlen = int_max(programlen, MAX_STR_LEN);
|
||||
programlen = int_min(programlen, MAX_STR_LEN);
|
||||
memcpy(field, handler->program, programlen);
|
||||
}
|
||||
|
||||
@ -1208,7 +1230,7 @@ setup_download_handler(struct session *ses, struct download *loading,
|
||||
type_query = init_type_query(ses, loading, cached);
|
||||
if (type_query) {
|
||||
ret = 1;
|
||||
type_query->copiousoutput = handler->copiousoutput;
|
||||
if (handler) type_query->copiousoutput = handler->copiousoutput;
|
||||
#ifdef CONFIG_BITTORRENT
|
||||
/* A terrible waste of a good MIME handler here, but we want
|
||||
* to use the type_query this is easier. */
|
||||
|
Loading…
Reference in New Issue
Block a user