[coreboot-gerrit] New patch to review for coreboot: console/vtxprintf.c: cast precision to size_t for string length

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Fri Nov 18 20:25:44 CET 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17479

-gerrit

commit 506df38eb3e4e80c6df9f641ba7f54cf66a5d70d
Author: Martin Roth <martinroth at google.com>
Date:   Fri Nov 18 11:35:01 2016 -0700

    console/vtxprintf.c: cast precision to size_t for string length
    
    If no maximum string length is specified, we're intentionally passing a
    value of -1 to get the string length so that it's not limited.  This
    makes checking tools unhappy, so actively cast it to size_t before
    passing it into strlen to show that it's not an accident.
    
    Addresses coverity issue 1129133 - Argument cannot be negative
    
    Change-Id: I40f8f2101e170a5c96fcd39c217aa414f4316473
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 src/console/vtxprintf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c
index d20a387..5f37253 100644
--- a/src/console/vtxprintf.c
+++ b/src/console/vtxprintf.c
@@ -228,7 +228,7 @@ repeat:
 			if (!s)
 				s = "<NULL>";
 
-			len = strnlen(s, precision);
+			len = strnlen(s, (size_t)precision);
 
 			if (!(flags & LEFT))
 				while (len < field_width--)



More information about the coreboot-gerrit mailing list