improve uint error handling to prevent crashes

This commit is contained in:
Zuki Air 2025-07-29 10:39:03 +01:00
parent efde7ce68e
commit eadf4ec650

View File

@ -1,9 +1,11 @@
From ba4bc854ec0e39030cde295e5019e56f598472b2 Mon Sep 17 00:00:00 2001
From fbaf5f3b5d57c9239ed822d307f7f0b71aa53b27 Mon Sep 17 00:00:00 2001
From: Zuki Air <zukirust@gmail.com>
Date: Sun, 27 Jul 2025 11:30:32 +0100
Subject: [PATCH] river-ctl patch
remove func argument and use the root argument instead
improve uint error handling
---
.gitignore | 1 +
Makefile | 22 +-
@ -11,8 +13,8 @@ remove func argument and use the root argument instead
dwl.c | 20 +-
dwlctl.c | 132 +++++
protocols/river-control-unstable-v1.xml | 85 +++
river-control.h | 715 ++++++++++++++++++++++++
7 files changed, 994 insertions(+), 15 deletions(-)
river-control.h | 722 ++++++++++++++++++++++++
7 files changed, 1001 insertions(+), 15 deletions(-)
create mode 100644 dwlctl.c
create mode 100644 protocols/river-control-unstable-v1.xml
create mode 100644 river-control.h
@ -437,10 +439,10 @@ index 0000000..aa5fc4d
+</protocol>
diff --git a/river-control.h b/river-control.h
new file mode 100644
index 0000000..297a47e
index 0000000..237a926
--- /dev/null
+++ b/river-control.h
@@ -0,0 +1,715 @@
@@ -0,0 +1,722 @@
+#include "river-control-unstable-v1-private-protocol.c"
+#include "river-control-unstable-v1-protocol.h"
+#ifdef KEYS_USED
@ -618,6 +620,7 @@ index 0000000..297a47e
+const char *zriver_error_no_matching_argument = "no matching argument";
+const char *zriver_error_double_appid = "set appid more then once!";
+const char *zriver_error_double_title = "set title more then once!";
+const char *zriver_error_under_zero = "argument needs to be more then zero!";
+#define STR_LINK_ARRAY_SIZE 10
+struct Str_link {
+ struct wl_list link;
@ -998,7 +1001,13 @@ index 0000000..297a47e
+ break;
+ case(FUNC_STR_ARG_TYPE_UINT):
+ // TODO make overflow check
+ arg->ui = strtol(argument,NULL,10);
+ arg->i = strtol(argument,NULL,10);
+ if (arg->i > 0) {
+ arg->ui = arg->i;
+ } else {
+ args->error = true;
+ args->error_msg = zriver_error_under_zero;
+ }
+ break;
+ case(FUNC_STR_ARG_TYPE_INT):
+ arg->i = strtol(argument,NULL,10);