Fix C std23 related warnings with new glibc.

C standard library functions now preserves qualifiers passed
to some functions. In case of strchr() if the passed argument is
const qualified also the returned value is const qualified. Similarly
if the passed argument is not const qualified neither is the return
value.

This patch makes libcryptsetup compliant with the change and should
be backward compatible with older std libraries.

Thanks Vojta Trefny for heads-up.
This commit is contained in:
Ondrej Kozina
2025-12-02 11:07:04 +01:00
parent f1ba606c28
commit a07c8a556c
5 changed files with 12 additions and 8 deletions

View File

@@ -1002,8 +1002,10 @@ static int TCRYPT_status_one(struct crypt_device *cd, const char *name,
{
struct crypt_dm_active_device dmd;
struct dm_target *tgt = &dmd.segment;
char dm_name[PATH_MAX], *c;
const char *c;
char dm_name[PATH_MAX];
int r;
size_t cipher_len = MAX_CIPHER_LEN;
if (snprintf(dm_name, sizeof(dm_name), "%s_%d", name, index) < 0)
return -ENOMEM;
@@ -1027,9 +1029,9 @@ static int TCRYPT_status_one(struct crypt_device *cd, const char *name,
if (is_tcrypt_subdev(dmd.uuid, base_uuid)) {
if ((c = strchr(tgt->u.crypt.cipher, '-')))
*c = '\0';
cipher_len = c - tgt->u.crypt.cipher;
strcat(cipher, "-");
strncat(cipher, tgt->u.crypt.cipher, MAX_CIPHER_LEN);
strncat(cipher, tgt->u.crypt.cipher, cipher_len);
*key_size += crypt_volume_key_length(tgt->u.crypt.vk);
tcrypt_hdr->d.mk_offset = tgt->u.crypt.offset * SECTOR_SIZE;
device_free(cd, *device);