Open vittyvk opened 10 months ago
ping?
FWIW, the message is misleading you into thinking it's a single \0 byte, but it's a \0 UCS-2 character (i.e. 2 bytes).
But yes I believe this is useful. It's not strictly necessary: As I'm sure you know, you can always append a space to the entry in the .csv and it works. But it's an ugly workaround for sure.
I can't speak to whether the implementation is otherwise correct as I haven't looked at it in detail, mostly just tracing the reasoning with my work. Generally I'd favor not copying trailing \0s, but append them explicitly again, but I don't have enough context in the code here.
The workaround using extra space is indeed known and is already used in the wild, e.g. https://gitlab.com/kraxel/virt-firmware/-/commit/77d3801ccc963da747ba576da0fe586d352615d3 but it probably takes some time to discover it. It'd be nice to have a permanent solution.
In case CSV entry contains boot argument (e.g. an image to load for shim) it must be null-terminated. While populate_stanza() makes sure 'arguments' end with '\0', add_boot_option() doesn't account for it in 'size' calculations. E.g. for the following CSV entry:
the resulting variable after 'fallback' looks like:
Add trailing '\0' to 'size' calculations in add_boot_option() when 'arguments' is not empty. The resulting variable looks like:
and the specified image is loaded by shim without issues.