From b9310665732074af596772266461d8a6ef1df1b7 Mon Sep 17 00:00:00 2001 From: o9000 Date: Tue, 27 Jun 2017 12:27:50 +0200 Subject: [PATCH] Executor: truncate very long tooltips --- src/execplugin/execplugin.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/execplugin/execplugin.c b/src/execplugin/execplugin.c index 34efae7..e2d221f 100644 --- a/src/execplugin/execplugin.c +++ b/src/execplugin/execplugin.c @@ -18,6 +18,8 @@ #include "timer.h" #include "common.h" +#define MAX_TOOLTIP_LEN 4096 + void execp_timer_callback(void *arg); char *execp_get_tooltip(void *obj); void execp_init_fonts(); @@ -794,6 +796,8 @@ gboolean read_execp(void *obj) start = execp->backend->buf_stderr; execp->backend->tooltip = strdup(start); rstrip(execp->backend->tooltip); + if (strlen(execp->backend->tooltip) > MAX_TOOLTIP_LEN) + execp->backend->tooltip[MAX_TOOLTIP_LEN] = '\0'; } execp->backend->buf_stderr_length = 0; execp->backend->buf_stderr[execp->backend->buf_stderr_length] = '\0'; @@ -812,6 +816,10 @@ gboolean read_execp(void *obj) memmove(execp->backend->buf_stderr, start, strlen(start) + 1); execp->backend->buf_stderr_length = (ssize_t)strlen(execp->backend->buf_stderr); } + if (execp->backend->buf_stderr_length > MAX_TOOLTIP_LEN) { + execp->backend->buf_stderr_length = MAX_TOOLTIP_LEN; + execp->backend->buf_stderr[execp->backend->buf_stderr_length] = '\0'; + } execp->backend->tooltip = strdup(execp->backend->buf_stderr); rstrip(execp->backend->tooltip); } else {