glibc 2.43 enables _ISOC23_SOURCE via _GNU_SOURCE, activating
type-generic macros for strchr/strstr that return const char *
when given a const char * input, surfacing const violations as
hard compile errors.

handler.c: attrs[i].name is typed const char * by libubox's struct,
but points into a locally malloc'd buffer. Use an explicit cast to
char * so the separator can be overwritten in place.

iprule.c: iprule_parse_mark() declared its parameter const but
overwrites the '/' separator in place via the strchr result. The
caller passes blobmsg_data() which is a mutable buffer, so drop
the const qualifier from the parameter.

system-linux.c: the local variable receiving strstr() in
system_add_devtype() is only read after assignment; change it from
char * to const char * to match the const char * input.

Signed-off-by: Dustin Lundquist <[email protected]>
---
 handler.c      | 2 +-
 iprule.c       | 2 +-
 system-linux.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/handler.c b/handler.c
index 78fc9a0..ba12172 100644
--- a/handler.c
+++ b/handler.c
@@ -312,7 +312,7 @@ netifd_handler_parse_config(struct uci_blob_param_list 
*config, json_object *obj
 
                attrs[i].name = str_cur;
                str_cur += sprintf(str_cur, "%s", name) + 1;
-               delim = strchr(attrs[i].name, ':');
+               delim = (char *)strchr(attrs[i].name, ':');
                if (delim) {
                        *delim = '\0';
                        validate[i] = ++delim;
diff --git a/iprule.c b/iprule.c
index 1fedac6..4a040d1 100644
--- a/iprule.c
+++ b/iprule.c
@@ -91,7 +91,7 @@ rule_ready(struct iprule *rule)
 }
 
 static bool
-iprule_parse_mark(const char *mark, struct iprule *rule)
+iprule_parse_mark(char *mark, struct iprule *rule)
 {
        char *s, *e;
        unsigned int n;
diff --git a/system-linux.c b/system-linux.c
index 8ff44a3..1dc18b5 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -3162,7 +3162,7 @@ system_add_devtype(struct blob_buf *b, const char *ifname)
                const char *line = strtok_r(buf, "\r\n", &context);
 
                while (line != NULL) {
-                       char *index = strstr(line, info);
+                       const char *index = strstr(line, info);
 
                        if (index != NULL) {
                                blobmsg_add_string(b, "devtype", index + 
strlen(info));

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to