Skip to content

Commit 9959d78

Browse files
committed
veritysetup: do some superficial checking on volume name
cryptsetup does this too, so let's better be safe here, too.
1 parent bb3ff7a commit 9959d78

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/veritysetup/veritysetup.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ static int run(int argc, char *argv[]) {
146146
root_hash = argv[5];
147147
options = mangle_none(argc > 6 ? argv[6] : NULL);
148148

149+
if (!filename_is_valid(volume))
150+
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Volume name '%s' is not valid.", volume);
151+
149152
r = unhexmem(root_hash, SIZE_MAX, &m, &l);
150153
if (r < 0)
151154
return log_error_errno(r, "Failed to parse root hash: %m");
@@ -210,6 +213,9 @@ static int run(int argc, char *argv[]) {
210213

211214
volume = argv[2];
212215

216+
if (!filename_is_valid(volume))
217+
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Volume name '%s' is not valid.", volume);
218+
213219
r = crypt_init_by_name(&cd, volume);
214220
if (r == -ENODEV) {
215221
log_info("Volume %s already inactive.", volume);

0 commit comments

Comments
 (0)