aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLexi Winter <ivy@FreeBSD.org>2026-08-03 14:05:09 +0000
committerLexi Winter <ivy@FreeBSD.org>2026-08-03 14:05:09 +0000
commitbcee560d390eb8aa8fd0f08a7a0bffb6e77fffc6 (patch)
treefadaceea461ad2b4890d08922aee9d59e8e02437
parentcb2daf8ce116d475597d7ab95f2454ea54c968e6 (diff)
libucl: Const correctness for C23
On some platforms, e.g. Linux Clang 22.1.8 / glibc 2.43, strchr() now implements the C23 behaviour where passing a const pointer to strchr() also returns a const pointer. This breaks libucl during the bootstrap build, since it assumes the return value is always a mutable pointer. Instead of assigning directly to params->prefix (which is const), use a non-const temporary variable and assign the result after we've done the modification. MFC after: 1 week Reviewed by: bofh, bapt Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58490
-rw-r--r--contrib/libucl/src/ucl_util.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/contrib/libucl/src/ucl_util.c b/contrib/libucl/src/ucl_util.c
index a56d8b27ad65..3b732a58701c 100644
--- a/contrib/libucl/src/ucl_util.c
+++ b/contrib/libucl/src/ucl_util.c
@@ -1088,7 +1088,7 @@ ucl_include_file_single(const unsigned char *data, size_t len,
bool res;
struct ucl_chunk *chunk;
unsigned char *buf = NULL;
- char *old_curfile, *ext;
+ char *old_curfile, *ext, *tmp;
size_t buflen = 0;
char filebuf[PATH_MAX], realbuf[PATH_MAX];
int prev_state;
@@ -1200,12 +1200,13 @@ ucl_include_file_single(const unsigned char *data, size_t len,
if (params->use_prefix && params->prefix == NULL) {
/* Auto generate a key name based on the included filename */
- params->prefix = basename(realbuf);
- ext = strrchr(params->prefix, '.');
+ tmp = basename(realbuf);
+ ext = strrchr(tmp, '.');
if (ext != NULL && (strcmp(ext, ".conf") == 0 || strcmp(ext, ".ucl") == 0)) {
/* Strip off .conf or .ucl */
*ext = '\0';
}
+ params->prefix = tmp;
}
if (params->prefix != NULL) {
/* This is a prefixed include */