From afe25df1be077a951a36f0359f22ad98b9ced343 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 19 Oct 2023 13:21:03 -0700 Subject: [PATCH] cros_fdt: allow newline in string values This is technically outside the spec - it says that strings are "printable" without further elaboration, which traditionally matches the ASCII characters in [0x20, 0x7f). However, ARCVM on ChromeOS uses a string value that contains newline (0x0a) characters, which means that the tightened range of allowed characters prevents the VM from booting. Allow 0x0a in addition to the normal printable ASCII characters to fix ARCVM boot. This should ideally be fixed on the ARCVM side, but allow it for now to unblock continued work on the FDT code without reverting. BUG=b:306454590 TEST=Boot ARCVM on hatch Change-Id: Ibe97417191319dc2dbec5ce067feb2ed7d463e04 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4956218 Reviewed-by: Lepton Wu Commit-Queue: Daniel Verkamp Reviewed-by: Junichi Uekawa --- cros_fdt/src/propval.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cros_fdt/src/propval.rs b/cros_fdt/src/propval.rs index 580067a3d8..da18a0b2c0 100644 --- a/cros_fdt/src/propval.rs +++ b/cros_fdt/src/propval.rs @@ -110,7 +110,9 @@ impl ToFdtPropval for Vec { fn is_valid_string_property(bytes: &[u8]) -> bool { const PRINTABLE_ASCII: std::ops::Range = 0x20..0x7f; - bytes.iter().all(|b| PRINTABLE_ASCII.contains(b)) + bytes + .iter() + .all(|b| PRINTABLE_ASCII.contains(b) || *b == 0x0a) } #[inline]