Skip to content

Commit 35f4a6d

Browse files
committed
opal output: add bozo input check
Without this check, gcc 14's static analyzer emits a warning about possible out-of-bounds array subscripts. Signed-off-by: Jeff Squyres <jeff@squyres.com>
1 parent d76dfdc commit 35f4a6d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

opal/util/output.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* reserved.
2323
* Copyright (c) 2019 Triad National Security, LLC. All rights
2424
* reserved.
25+
* Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
2526
* $COPYRIGHT$
2627
*
2728
* Additional copyrights may follow
@@ -574,6 +575,13 @@ static int do_open(int output_id, opal_output_stream_t *lds)
574575
opal_output_init();
575576
}
576577

578+
/* Bozo check */
579+
580+
if (output_id >= OPAL_OUTPUT_MAX_STREAMS ||
581+
output_id < -1) {
582+
return OPAL_ERR_BAD_PARAM;
583+
}
584+
577585
str = getenv("OPAL_OUTPUT_REDIRECT");
578586
if (NULL != str && 0 == strcasecmp(str, "file")) {
579587
redirect_to_file = true;

0 commit comments

Comments
 (0)