@@ -381,10 +381,10 @@ gboolean bd_crypto_is_tech_avail (BDCryptoTech tech, guint64 mode, GError **erro
381381 case BD_CRYPTO_TECH_LUKS :
382382 ret = mode & (BD_CRYPTO_TECH_MODE_CREATE |BD_CRYPTO_TECH_MODE_OPEN_CLOSE |BD_CRYPTO_TECH_MODE_QUERY |
383383 BD_CRYPTO_TECH_MODE_ADD_KEY |BD_CRYPTO_TECH_MODE_REMOVE_KEY |BD_CRYPTO_TECH_MODE_RESIZE |
384- BD_CRYPTO_TECH_MODE_SUSPEND_RESUME |BD_CRYPTO_TECH_MODE_BACKUP_RESTORE );
384+ BD_CRYPTO_TECH_MODE_SUSPEND_RESUME |BD_CRYPTO_TECH_MODE_BACKUP_RESTORE | BD_CRYPTO_TECH_MODE_MODIFY );
385385 if (ret != mode ) {
386386 g_set_error_literal (error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_TECH_UNAVAIL ,
387- "Only 'create', 'open', 'query', 'add-key', 'remove-key', 'resize', 'suspend-resume', 'backup-restore' supported for LUKS" );
387+ "Only 'create', 'open', 'query', 'add-key', 'remove-key', 'resize', 'suspend-resume', 'backup-restore', 'modify' supported for LUKS" );
388388 return FALSE;
389389 } else
390390 return TRUE;
@@ -1023,11 +1023,31 @@ gboolean _crypto_luks_format (const gchar *device,
10231023 if (min_entropy > 0 ) {
10241024 dev_random_fd = open ("/dev/random" , O_RDONLY );
10251025 if (dev_random_fd >= 0 ) {
1026- ioctl (dev_random_fd , RNDGETENTCNT , & current_entropy );
1026+ if (ioctl (dev_random_fd , RNDGETENTCNT , & current_entropy ) < 0 ) {
1027+ g_set_error (& l_error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_FORMAT_FAILED ,
1028+ "Failed to get random data entropy level: %s" ,
1029+ strerror_l (errno , c_locale ));
1030+ close (dev_random_fd );
1031+ crypt_free (cd );
1032+ g_strfreev (cipher_specs );
1033+ bd_utils_report_finished (progress_id , l_error -> message );
1034+ g_propagate_error (error , l_error );
1035+ return FALSE;
1036+ }
10271037 while (current_entropy < min_entropy ) {
10281038 bd_utils_report_progress (progress_id , 0 , "Waiting for enough random data entropy" );
10291039 sleep (1 );
1030- ioctl (dev_random_fd , RNDGETENTCNT , & current_entropy );
1040+ if (ioctl (dev_random_fd , RNDGETENTCNT , & current_entropy ) < 0 ) {
1041+ g_set_error (& l_error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_FORMAT_FAILED ,
1042+ "Failed to get random data entropy level: %s" ,
1043+ strerror_l (errno , c_locale ));
1044+ close (dev_random_fd );
1045+ crypt_free (cd );
1046+ g_strfreev (cipher_specs );
1047+ bd_utils_report_finished (progress_id , l_error -> message );
1048+ g_propagate_error (error , l_error );
1049+ return FALSE;
1050+ }
10311051 }
10321052 close (dev_random_fd );
10331053 } else {
@@ -1422,6 +1442,7 @@ static gboolean _crypto_close (const gchar *device, const gchar *tech_name, GErr
14221442 if (ret != 0 ) {
14231443 g_set_error (& l_error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
14241444 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
1445+ crypt_free (cd );
14251446 bd_utils_report_finished (progress_id , l_error -> message );
14261447 g_propagate_error (error , l_error );
14271448 return FALSE;
@@ -1828,6 +1849,7 @@ gboolean bd_crypto_luks_resize (const gchar *luks_device, guint64 size, BDCrypto
18281849 if (ret != 0 ) {
18291850 g_set_error (& l_error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
18301851 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
1852+ crypt_free (cd );
18311853 bd_utils_report_finished (progress_id , l_error -> message );
18321854 g_propagate_error (error , l_error );
18331855 return FALSE;
@@ -1937,6 +1959,7 @@ gboolean bd_crypto_luks_suspend (const gchar *luks_device, GError **error) {
19371959 if (ret != 0 ) {
19381960 g_set_error (& l_error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
19391961 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
1962+ crypt_free (cd );
19401963 bd_utils_report_finished (progress_id , l_error -> message );
19411964 g_propagate_error (error , l_error );
19421965 return FALSE;
@@ -1986,6 +2009,7 @@ gboolean bd_crypto_luks_resume (const gchar *luks_device, BDCryptoKeyslotContext
19862009 if (ret != 0 ) {
19872010 g_set_error (& l_error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
19882011 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
2012+ crypt_free (cd );
19892013 bd_utils_report_finished (progress_id , l_error -> message );
19902014 g_propagate_error (error , l_error );
19912015 return FALSE;
@@ -2587,6 +2611,7 @@ BDCryptoLUKSInfo* bd_crypto_luks_info (const gchar *device, GError **error) {
25872611 if (ret != 0 ) {
25882612 g_set_error (error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
25892613 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
2614+ crypt_free (cd );
25902615 return NULL ;
25912616 }
25922617
@@ -2742,6 +2767,7 @@ BDCryptoIntegrityInfo* bd_crypto_integrity_info (const gchar *device, GError **e
27422767 if (ret != 0 ) {
27432768 g_set_error (error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
27442769 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
2770+ crypt_free (cd );
27452771 return NULL ;
27462772 }
27472773
@@ -2811,6 +2837,7 @@ BDCryptoLUKSTokenInfo** bd_crypto_luks_token_info (const gchar *device, GError *
28112837 if (ret != 0 ) {
28122838 g_set_error (error , BD_CRYPTO_ERROR , BD_CRYPTO_ERROR_DEVICE ,
28132839 "Failed to initialize device: %s" , strerror_l (- ret , c_locale ));
2840+ crypt_free (cd );
28142841 return NULL ;
28152842 }
28162843
0 commit comments