aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/config.c5
-rw-r--r--rootston/ini.c2
-rw-r--r--rootston/xwayland.c48
3 files changed, 25 insertions, 30 deletions
diff --git a/rootston/config.c b/rootston/config.c
index 0883f6d4..67bf83e9 100644
--- a/rootston/config.c
+++ b/rootston/config.c
@@ -418,7 +418,10 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
char cwd[MAXPATHLEN];
if (getcwd(cwd, sizeof(cwd)) != NULL) {
char buf[MAXPATHLEN];
- snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "rootston.ini");
+ if (snprintf(buf, MAXPATHLEN, "%s/%s", cwd, "rootston.ini") >= MAXPATHLEN) {
+ wlr_log(L_ERROR, "config path too long");
+ exit(1);
+ }
config->config_path = strdup(buf);
} else {
wlr_log(L_ERROR, "could not get cwd");
diff --git a/rootston/ini.c b/rootston/ini.c
index 56cc9ea6..f515dd38 100644
--- a/rootston/ini.c
+++ b/rootston/ini.c
@@ -64,7 +64,7 @@ static char* find_chars_or_comment(const char* s, const char* chars)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
- strncpy(dest, src, size);
+ strncpy(dest, src, size-1);
dest[size - 1] = '\0';
return dest;
}
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 27a27b65..b7dbab54 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -228,19 +228,31 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
static void handle_map(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, map);
- struct wlr_xwayland_surface *xsurface = data;
+ struct wlr_xwayland_surface *surface = data;
struct roots_view *view = roots_surface->view;
- view->x = xsurface->x;
- view->y = xsurface->y;
- view->width = xsurface->surface->current->width;
- view->height = xsurface->surface->current->height;
-
- view_map(view, xsurface->surface);
+ view->x = surface->x;
+ view->y = surface->y;
+ view->width = surface->surface->current->width;
+ view->height = surface->surface->current->height;
roots_surface->surface_commit.notify = handle_surface_commit;
- wl_signal_add(&xsurface->surface->events.commit,
+ wl_signal_add(&surface->surface->events.commit,
&roots_surface->surface_commit);
+
+ view_map(view, surface->surface);
+
+ if (!surface->override_redirect) {
+ if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {
+ view->decorated = true;
+ view->border_width = 4;
+ view->titlebar_height = 12;
+ }
+
+ view_setup(view);
+ } else {
+ view_initial_focus(view);
+ }
}
static void handle_unmap(struct wl_listener *listener, void *data) {
@@ -289,10 +301,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_signal_add(&surface->events.request_fullscreen,
&roots_surface->request_fullscreen);
- roots_surface->surface_commit.notify = handle_surface_commit;
- wl_signal_add(&surface->surface->events.commit,
- &roots_surface->surface_commit);
-
struct roots_view *view = view_create(desktop);
if (view == NULL) {
free(roots_surface);
@@ -301,8 +309,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->type = ROOTS_XWAYLAND_VIEW;
view->x = (double)surface->x;
view->y = (double)surface->y;
- view->width = surface->surface->current->width;
- view->height = surface->surface->current->height;
view->xwayland_surface = surface;
view->roots_xwayland_surface = roots_surface;
@@ -315,18 +321,4 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->close = close;
view->destroy = destroy;
roots_surface->view = view;
-
- view_map(view, surface->surface);
-
- if (!surface->override_redirect) {
- if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {
- view->decorated = true;
- view->border_width = 4;
- view->titlebar_height = 12;
- }
-
- view_setup(view);
- } else {
- view_initial_focus(view);
- }
}