verity: fix strncpy boundary check compiler warning

lib/verity/verity.c: In function ‘VERITY_write_sb’:
lib/verity/verity.c:200:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
  strncpy(algorithm, params->hash_name, sizeof(sb.algorithm));
This commit is contained in:
Luca Boccassi
2021-01-25 14:26:24 +00:00
parent 24d349f491
commit 39dc77d825

View File

@@ -197,7 +197,7 @@ int VERITY_write_sb(struct crypt_device *cd,
/* Kernel always use lower-case */
algorithm = (char *)sb.algorithm;
strncpy(algorithm, params->hash_name, sizeof(sb.algorithm));
strncpy(algorithm, params->hash_name, sizeof(sb.algorithm)-1);
algorithm[sizeof(sb.algorithm)-1] = '\0';
_to_lower(algorithm);