render: limit length of title in call to xdg_toplevel_set_title()

Trying to pass a too long title (not sure what "too long" is
though...) will trigger a call to abort() inside the wayland-client
library.
This commit is contained in:
Daniel Eklöf 2019-11-01 20:25:44 +01:00
parent bc815a33db
commit dac1ba18c8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -950,9 +950,21 @@ render_resize(struct terminal *term, int width, int height)
}
void
render_set_title(struct terminal *term, const char *title)
render_set_title(struct terminal *term, const char *_title)
{
/* TODO: figure out what the limit actually is */
static const size_t max_len = 100;
const char *title = _title;
char *copy = NULL;
if (strlen(title) > max_len) {
copy = strndup(_title, max_len);
title = copy;
}
xdg_toplevel_set_title(term->window->xdg_toplevel, title);
free(copy);
}
void