logo

inaban

Distrustful Wayland Compositor (inspired by XMonad and dwm) git clone https://hacktivis.me/git/inaban.git
commit: 3d51fa19b1cf9d6e46a03399b9ed5325cd42726b
parent ab4e50b651899fc2a01b4eabf003aab98e058bc3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri,  1 Jan 2021 07:06:53 +0100

Stop -s arguments from erasing the first one

Diffstat:

Minaban.c21++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/inaban.c b/inaban.c @@ -16,6 +16,7 @@ #include <unistd.h> #define LENGTH(X) (sizeof X / sizeof X[0]) +#define MAX_STARTUP_CMD 256 struct inaban_server server = {0}; @@ -616,9 +617,9 @@ int main(int argc, char *argv[]) { wlr_log_init(WLR_DEBUG, NULL); - char *startup_cmdv[] = {NULL}; - int startup_cmdc = 0; - int ret = 0; + char *startup_cmdv[MAX_STARTUP_CMD] = {NULL}; + int startup_cmdc = 0; + int ret = 0; struct wlr_server_decoration_manager *server_decoration_manager = NULL; @@ -637,8 +638,18 @@ main(int argc, char *argv[]) switch(c) { case 's': - startup_cmdv[startup_cmdc] = optarg; - startup_cmdc++; + if(startup_cmdc < MAX_STARTUP_CMD) + { + startup_cmdv[startup_cmdc] = optarg; + startup_cmdc++; + } + else + { + wlr_log(WLR_INFO, + "Ignoring ā€˜-s %sā€™, max number of startup commands (%d) reached.", + optarg, + MAX_STARTUP_CMD); + } break; default: usage(argv[0]); return 0; }