Skip to content

Commit fc85255

Browse files
committed
Refs #16881: Protect args.certs_path
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
1 parent 3e1ac75 commit fc85255

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

test/run_test.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,14 +583,18 @@ def get_configurations(config_params, intraprocess, shm, security):
583583

584584
if security is not None:
585585
if os.path.isfile(config_params['properties']['SECURITY']):
586-
props_file = open(config_params['properties']['SECURITY'], "r+")
587-
data = props_file.read()
588-
#Replace all occurrences of the required label
589-
data = data.replace('<CERTS_RELATIVE_PATH>', args.certs_path)
590-
props_file.seek(0)
591-
props_file.write(data)
592-
props_file.truncate()
593-
props_file.close()
586+
if os.path.isfile(args.certs_path):
587+
props_file = open(config_params['properties']['SECURITY'], "r+")
588+
data = props_file.read()
589+
#Replace all occurrences of the required label
590+
data = data.replace('<CERTS_RELATIVE_PATH>', args.certs_path)
591+
props_file.seek(0)
592+
props_file.write(data)
593+
props_file.truncate()
594+
props_file.close()
595+
else:
596+
logger.error('Certs file not found at ' + args.certs_path)
597+
exit(1)
594598
else:
595599
logger.error('Properties file not found at ' + config_params['properties']['SECURITY'])
596600
exit(1)

0 commit comments

Comments
 (0)