Thomas Heijligen submitted this change.

View Change


Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, but someone else must approve Angel Pons: Looks good to me, but someone else must approve Anastasia Klimchuk: Looks good to me, approved
layout.c: Cast argument of isspace() to unsigned char

These functions [isspace, etc] check whether c [(the argument)], which
must have the value of an unsigned char or EOF, falls into a certain
character class according to the current locale.

Cast the argument from `char` to `unsigned char` to guarantee that
we don't pass illegal negative values. Some implementations actually
provide a warning to get heads up[1].

[1] https://man.netbsd.org/ctype.3#CAVEATS

TEST=Builds on Cygwin (Windows 10, amd64, gcc 11.3.0)

Change-Id: Ia48d5a19b0964bc28e5360edf06bdf287dad5945
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66548
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
---
M layout.c
1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/layout.c b/layout.c
index 39f504a..5916d66 100644
--- a/layout.c
+++ b/layout.c
@@ -312,7 +312,7 @@
entry->file = strdup(entry->name);

for (i = 0; entry->file[i]; ++i) {
- if (isspace(entry->file[i]))
+ if (isspace((unsigned char)entry->file[i]))
entry->file[i] = '_';
}
}

To view, visit change 66548. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ia48d5a19b0964bc28e5360edf06bdf287dad5945
Gerrit-Change-Number: 66548
Gerrit-PatchSet: 8
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Evan Benn <evanbenn@google.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-CC: Felix Singer <felixsinger@posteo.net>
Gerrit-MessageType: merged