[PATCH] odhcp6c: fix const-correctness for glibc 2.43 strpbrk
Dustin Lundquist
dustin at null-ptr.net
Tue Jun 2 12:40:11 PDT 2026
glibc 2.43 enables _ISOC23_SOURCE via _GNU_SOURCE, activating
type-generic macros for strpbrk/strchr/strstr that return
const char * when given a const char * input, surfacing const
violations as hard compile errors.
The config_parse_opt* functions declared their src/data/opt
parameters const but performed in-place tokenisation by writing
through the pointer (e.g. *sep = 0). All callers pass mutable
buffers (optarg or locally allocated strings), so drop the const
qualifiers throughout.
Signed-off-by: Dustin Lundquist <dustin at null-ptr.net>
---
src/config.c | 12 ++++++------
src/config.h | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/config.c b/src/config.c
index 54e2d35..614ff4b 100644
--- a/src/config.c
+++ b/src/config.c
@@ -335,7 +335,7 @@ static int config_parse_opt_u8(const char *src, uint8_t **dst)
return script_unhexlify(*dst, len, src);
}
-static int config_parse_opt_string(const char *src, uint8_t **dst, const bool array)
+static int config_parse_opt_string(char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
char *sep = strpbrk(src, ARRAY_SEP);
@@ -368,7 +368,7 @@ static int config_parse_opt_string(const char *src, uint8_t **dst, const bool ar
return o_len;
}
-static int config_parse_opt_dns_string(const char *src, uint8_t **dst, const bool array)
+static int config_parse_opt_dns_string(char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
char *sep = strpbrk(src, ARRAY_SEP);
@@ -405,7 +405,7 @@ static int config_parse_opt_dns_string(const char *src, uint8_t **dst, const boo
return o_len;
}
-static int config_parse_opt_ip6(const char *src, uint8_t **dst, const bool array)
+static int config_parse_opt_ip6(char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
char *sep = strpbrk(src, ARRAY_SEP);
@@ -439,7 +439,7 @@ static int config_parse_opt_ip6(const char *src, uint8_t **dst, const bool array
return o_len;
}
-static int config_parse_opt_user_class(const char *src, uint8_t **dst, const bool array)
+static int config_parse_opt_user_class(char *src, uint8_t **dst, const bool array)
{
int o_len = 0;
char *sep = strpbrk(src, ARRAY_SEP);
@@ -510,7 +510,7 @@ int config_add_opt(const uint16_t code, const uint8_t *data, const uint16_t len)
return 0;
}
-int config_parse_opt_data(const char *data, uint8_t **dst, const unsigned int type,
+int config_parse_opt_data(char *data, uint8_t **dst, const unsigned int type,
const bool array)
{
int ret = 0;
@@ -544,7 +544,7 @@ int config_parse_opt_data(const char *data, uint8_t **dst, const unsigned int ty
return ret;
}
-int config_parse_opt(const char *opt)
+int config_parse_opt(char *opt)
{
uint32_t optn;
char *data;
diff --git a/src/config.h b/src/config.h
index 91713de..1f85942 100644
--- a/src/config.h
+++ b/src/config.h
@@ -130,8 +130,8 @@ bool config_set_auth_token(const char* token);
void config_set_client_opt_cfg(struct odhcp6c_opt_cfg *opt_cfg);
int config_add_opt(const uint16_t code, const uint8_t *data, const uint16_t len);
-int config_parse_opt_data(const char *data, uint8_t **dst, const unsigned int type, const bool array);
-int config_parse_opt(const char *opt);
+int config_parse_opt_data(char *data, uint8_t **dst, const unsigned int type, const bool array);
+int config_parse_opt(char *opt);
void config_apply_dhcp_rtx(struct dhcpv6_retx* dhcpv6_retx);
More information about the openwrt-devel
mailing list