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 <lepton@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
This commit is contained in:
Daniel Verkamp 2023-10-19 13:21:03 -07:00 committed by crosvm LUCI
parent 52b23100a8
commit afe25df1be

View file

@ -110,7 +110,9 @@ impl ToFdtPropval for Vec<u64> {
fn is_valid_string_property(bytes: &[u8]) -> bool {
const PRINTABLE_ASCII: std::ops::Range<u8> = 0x20..0x7f;
bytes.iter().all(|b| PRINTABLE_ASCII.contains(b))
bytes
.iter()
.all(|b| PRINTABLE_ASCII.contains(b) || *b == 0x0a)
}
#[inline]