From 64ee1530ee55f70a5e65d80cbf584971d7beb1e4 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Thu, 21 Mar 2013 13:02:46 +0800 Subject: crossystem: Fix cros_debug detection on non-chrome systems. "cros_debug" is usually the last token of kernel command line on UEFI/legacy BIOS systems. However, kernel command line may end with new line ("\n") and that may cause strcmp to fail (i.e., can't detect "cros_debug" if it's the last parameter in command line), so we need to add that into strtok delimiters. BRANCH=none BUG=chromium:222248 TEST=crossystem cros_debug # display 1 on UEFI system with cros_debug Change-Id: I9aed1562291469118acbadcc5211ff5c45eb9feb Reviewed-on: https://gerrit.chromium.org/gerrit/46106 Tested-by: Hung-Te Lin Reviewed-by: Bill Richardson Commit-Queue: Hung-Te Lin --- host/lib/crossystem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c index c4d0a607..2ef222b0 100644 --- a/host/lib/crossystem.c +++ b/host/lib/crossystem.c @@ -129,6 +129,7 @@ int VbGetCrosDebug(void) { FILE* f = NULL; char buf[4096] = ""; char *t, *saveptr; + const char *delimiters = " \r\n"; /* If the currently running system specifies its debug status, use * that in preference to other indicators. */ @@ -138,7 +139,8 @@ int VbGetCrosDebug(void) { buf[0] = 0; fclose(f); } - for (t = strtok_r(buf, " ", &saveptr); t; t=strtok_r(NULL, " ", &saveptr)) { + for (t = strtok_r(buf, delimiters, &saveptr); t; + t = strtok_r(NULL, delimiters, &saveptr)) { if (0 == strcmp(t, "cros_debug")) return 1; else if (0 == strcmp(t, "cros_nodebug")) -- cgit v1.2.1