@@ -241,10 +241,11 @@ void dm_ima_measure_on_table_load(struct dm_table *table, unsigned int status_fl
241
241
/*
242
242
* First retrieve the target metadata.
243
243
*/
244
- scnprintf (target_metadata_buf , DM_IMA_TARGET_METADATA_BUF_LEN ,
245
- "target_index=%d,target_begin=%llu,target_len=%llu," ,
246
- i , ti -> begin , ti -> len );
247
- target_metadata_buf_len = strlen (target_metadata_buf );
244
+ target_metadata_buf_len =
245
+ scnprintf (target_metadata_buf ,
246
+ DM_IMA_TARGET_METADATA_BUF_LEN ,
247
+ "target_index=%d,target_begin=%llu,target_len=%llu," ,
248
+ i , ti -> begin , ti -> len );
248
249
249
250
/*
250
251
* Then retrieve the actual target data.
@@ -448,11 +449,9 @@ void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap)
448
449
if (r )
449
450
goto error ;
450
451
451
- scnprintf (device_table_data , DM_IMA_DEVICE_BUF_LEN ,
452
- "%sname=%s,uuid=%s;device_resume=no_data;" ,
453
- DM_IMA_VERSION_STR , dev_name , dev_uuid );
454
- l = strlen (device_table_data );
455
-
452
+ l = scnprintf (device_table_data , DM_IMA_DEVICE_BUF_LEN ,
453
+ "%sname=%s,uuid=%s;device_resume=no_data;" ,
454
+ DM_IMA_VERSION_STR , dev_name , dev_uuid );
456
455
}
457
456
458
457
capacity_len = strlen (capacity_str );
@@ -561,10 +560,9 @@ void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all)
561
560
if (dm_ima_alloc_and_copy_name_uuid (md , & dev_name , & dev_uuid , noio ))
562
561
goto error ;
563
562
564
- scnprintf (device_table_data , DM_IMA_DEVICE_BUF_LEN ,
565
- "%sname=%s,uuid=%s;device_remove=no_data;" ,
566
- DM_IMA_VERSION_STR , dev_name , dev_uuid );
567
- l = strlen (device_table_data );
563
+ l = scnprintf (device_table_data , DM_IMA_DEVICE_BUF_LEN ,
564
+ "%sname=%s,uuid=%s;device_remove=no_data;" ,
565
+ DM_IMA_VERSION_STR , dev_name , dev_uuid );
568
566
}
569
567
570
568
memcpy (device_table_data + l , remove_all_str , remove_all_len );
@@ -647,10 +645,9 @@ void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map)
647
645
if (dm_ima_alloc_and_copy_name_uuid (md , & dev_name , & dev_uuid , noio ))
648
646
goto error2 ;
649
647
650
- scnprintf (device_table_data , DM_IMA_DEVICE_BUF_LEN ,
651
- "%sname=%s,uuid=%s;table_clear=no_data;" ,
652
- DM_IMA_VERSION_STR , dev_name , dev_uuid );
653
- l = strlen (device_table_data );
648
+ l = scnprintf (device_table_data , DM_IMA_DEVICE_BUF_LEN ,
649
+ "%sname=%s,uuid=%s;table_clear=no_data;" ,
650
+ DM_IMA_VERSION_STR , dev_name , dev_uuid );
654
651
}
655
652
656
653
capacity_len = strlen (capacity_str );
@@ -706,7 +703,7 @@ void dm_ima_measure_on_device_rename(struct mapped_device *md)
706
703
char * old_device_data = NULL , * new_device_data = NULL , * combined_device_data = NULL ;
707
704
char * new_dev_name = NULL , * new_dev_uuid = NULL , * capacity_str = NULL ;
708
705
bool noio = true;
709
- int r ;
706
+ int r , len ;
710
707
711
708
if (dm_ima_alloc_and_copy_device_data (md , & new_device_data ,
712
709
md -> ima .active_table .num_targets , noio ))
@@ -728,12 +725,11 @@ void dm_ima_measure_on_device_rename(struct mapped_device *md)
728
725
md -> ima .active_table .device_metadata = new_device_data ;
729
726
md -> ima .active_table .device_metadata_len = strlen (new_device_data );
730
727
731
- scnprintf (combined_device_data , DM_IMA_DEVICE_BUF_LEN * 2 ,
732
- "%s%snew_name=%s,new_uuid=%s;%s" , DM_IMA_VERSION_STR , old_device_data ,
733
- new_dev_name , new_dev_uuid , capacity_str );
728
+ len = scnprintf (combined_device_data , DM_IMA_DEVICE_BUF_LEN * 2 ,
729
+ "%s%snew_name=%s,new_uuid=%s;%s" , DM_IMA_VERSION_STR , old_device_data ,
730
+ new_dev_name , new_dev_uuid , capacity_str );
734
731
735
- dm_ima_measure_data ("dm_device_rename" , combined_device_data , strlen (combined_device_data ),
736
- noio );
732
+ dm_ima_measure_data ("dm_device_rename" , combined_device_data , len , noio );
737
733
738
734
goto exit ;
739
735
0 commit comments