Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41280 )
Change subject: security/tpm/tspi/crtm.c: Fix handling of white space delimited list ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/c/coreboot/+/41280/3/src/security/tpm/tspi/crtm.... File src/security/tpm/tspi/crtm.c:
https://review.coreboot.org/c/coreboot/+/41280/3/src/security/tpm/tspi/crtm.... PS3, Line 100: == whitelist_len
We can do in a special commit but let's take this one here as it is since it is the first patch for […]
If you want to add strtok there's a decent version in libpayload (based on strspn that we already have) you could just copy. But I'm not sure it's the best solution for this.
https://review.coreboot.org/c/coreboot/+/41280/4/src/security/tpm/tspi/crtm.... File src/security/tpm/tspi/crtm.c:
https://review.coreboot.org/c/coreboot/+/41280/4/src/security/tpm/tspi/crtm.... PS4, Line 97: strcpy(tmp, whitelist); I don't think you really need to copy the string every time this is called... if you already know the end to which you want to compare, you can just use strncmp() instead of setting it to '\0'. And you could use strchr() to find the token end which might make it a bit easier. How about this:
const char *end; const char *token = whitelist; while ((end = strchr(token, ' '))) { if (!strncmp(token, name, end - token) return true; entry = end + 1; } if (!strcmp(token, name)) return true; return false;