diff mbox series

lib: fwts_log: fix the potential overflow for dumping all log fields

Message ID 20250512144921.27555-5-ivan.hu@canonical.com
State Accepted
Headers show
Series lib: fwts_log: fix the potential overflow for dumping all log fields | expand

Commit Message

Ivan Hu May 12, 2025, 2:49 p.m. UTC
Buglink: https://bugs.launchpad.net/fwts/+bug/2110180

Got coverity scan warning,

CID 520641: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW)
overflow_const: Expression field, overflows the type of field, which is type
fwts_log_field.

Simply add the for loop range for get rid of coverity scan warning.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/src/fwts_log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
index 48240201..2cac0b04 100644
--- a/src/lib/src/fwts_log.c
+++ b/src/lib/src/fwts_log.c
@@ -204,7 +204,7 @@  void fwts_log_print_fields(void)
 	fwts_log_field field;
 
 	printf("Available fields: ");
-	for (field = 1; ; field <<= 1) {
+	for (field = 1; field <= LOG_NO_FIELDS; field <<= 1) {
 		char *str = fwts_log_field_to_str(field);
 		if (strcmp(str, LOG_UNKNOWN_FIELD) == 0)
 			break;