1717#include "terminal-util.h"
1818
1919static uint32_t arg_activate_flags = CRYPT_ACTIVATE_READONLY ;
20- static const char * arg_root_hash_signature = NULL ;
20+ static char * arg_root_hash_signature = NULL ;
21+
22+ STATIC_DESTRUCTOR_REGISTER (arg_root_hash_signature , freep );
2123
2224static int help (void ) {
2325 _cleanup_free_ char * link = NULL ;
@@ -39,13 +41,17 @@ static int help(void) {
3941}
4042
4143static int save_roothashsig_option (const char * option , bool strict ) {
44+ int r ;
4245
4346 if (path_is_absolute (option ) || startswith (option , "base64:" )) {
4447 if (!HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY )
4548 return log_error_errno (SYNTHETIC_ERRNO (EOPNOTSUPP ),
4649 "Activation of verity device with signature requested, but cryptsetup does not support crypt_activate_by_signed_key()." );
4750
48- arg_root_hash_signature = option ;
51+ r = free_and_strdup_warn (& arg_root_hash_signature , option );
52+ if (r < 0 )
53+ return r ;
54+
4955 return true;
5056 }
5157
@@ -60,10 +66,10 @@ static int parse_options(const char *options) {
6066 int r ;
6167
6268 /* backward compatibility with the obsolete ROOTHASHSIG positional argument */
63- r = save_roothashsig_option (options , false);
69+ r = save_roothashsig_option (options , /* strict= */ false);
6470 if (r < 0 )
6571 return r ;
66- if (r == 1 ) {
72+ if (r > 0 ) {
6773 log_warning ("Usage of ROOTHASHSIG positional argument is deprecated. "
6874 "Please use the option root-hash-signature=%s instead." , options );
6975 return 0 ;
@@ -99,7 +105,7 @@ static int parse_options(const char *options) {
99105 arg_activate_flags |= CRYPT_ACTIVATE_PANIC_ON_CORRUPTION ;
100106#endif
101107 else if ((val = startswith (word , "root-hash-signature=" ))) {
102- r = save_roothashsig_option (val , true);
108+ r = save_roothashsig_option (val , /* strict= */ true);
103109 if (r < 0 )
104110 return r ;
105111
0 commit comments