mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
Yet another fix for header strings.
This commit is contained in:
@@ -726,14 +726,14 @@ int LUKS2_luks2_to_luks1(struct crypt_device *cd, struct luks2_hdr *hdr2, struct
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
strncpy(hdr1->cipherName, cipher, sizeof(hdr1->cipherName));
|
||||
strncpy(hdr1->cipherMode, cipher_mode, sizeof(hdr1->cipherMode));
|
||||
strncpy(hdr1->cipherName, cipher, sizeof(hdr1->cipherName) - 1);
|
||||
strncpy(hdr1->cipherMode, cipher_mode, sizeof(hdr1->cipherMode) - 1);
|
||||
|
||||
if (!json_object_object_get_ex(jobj_keyslot, "kdf", &jobj_kdf))
|
||||
return -EINVAL;
|
||||
if (!json_object_object_get_ex(jobj_kdf, "hash", &jobj1))
|
||||
return -EINVAL;
|
||||
strncpy(hdr1->hashSpec, json_object_get_string(jobj1), sizeof(hdr1->hashSpec));
|
||||
strncpy(hdr1->hashSpec, json_object_get_string(jobj1), sizeof(hdr1->hashSpec) - 1);
|
||||
|
||||
hdr1->keyBytes = key_size;
|
||||
|
||||
|
||||
@@ -169,15 +169,16 @@ static void release_lock_handle(struct crypt_lock_handle *h)
|
||||
char res[PATH_MAX];
|
||||
struct stat buf_a, buf_b;
|
||||
|
||||
/* coverity[toctou] */
|
||||
if (S_ISBLK(h->mode) && /* was it block device */
|
||||
!flock(h->flock_fd, LOCK_EX | LOCK_NB) && /* lock to drop the file */
|
||||
!resource_by_devno(res, sizeof(res), h->devno, 1) && /* acquire lock resource name */
|
||||
!fstat(h->flock_fd, &buf_a) && /* read inode id refered by fd */
|
||||
!stat(res, &buf_b) && /* does path file stil exist? */
|
||||
same_inode(buf_a, buf_b)) /* is it same id as the one referenced by fd? */
|
||||
same_inode(buf_a, buf_b)) { /* is it same id as the one referenced by fd? */
|
||||
/* coverity[toctou] */
|
||||
if (unlink(res)) /* yes? unlink the file */
|
||||
log_dbg("Failed to unlink resource file: %s", res);
|
||||
}
|
||||
|
||||
if (close(h->flock_fd))
|
||||
log_dbg("Failed to close resource fd (%d).", h->flock_fd);
|
||||
|
||||
Reference in New Issue
Block a user