]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
include/xen/xen.h: Add warning comment for cmd_line
authorAaron Rainbolt <arraybolt3@gmail.com>
Thu, 14 Aug 2025 01:36:44 +0000 (20:36 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 3 Sep 2025 15:44:26 +0000 (17:44 +0200)
The cmd_line field of the start_info struct is not guaranteed to be
NUL-terminated, even though it is intended to contain a NUL-terminated
string. Add a warning about this in a comment so future consumers of
this field know to check it for a NUL terminator before using it.

Signed-off-by: Aaron Rainbolt <arraybolt3@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
include/xen/xen.h

index fdf0fc44884c2eca1599e4c99ec4a9ee61428a95..4c21fb5ef7f41cff0502399c7a9f1c68789f7fcc 100644 (file)
@@ -823,6 +823,11 @@ struct start_info {
                                 /* (PFN of pre-loaded module if           */
                                 /*  SIF_MOD_START_PFN set in flags).      */
     unsigned long mod_len;      /* Size (bytes) of pre-loaded module.     */
+    /*
+     * cmd_line will contain a NUL-termianted string if it contains valid
+     * data, but it MAY be invalid and not contain a NUL byte at all. Code
+     * that accesses cmd_line MUST NOT assume it is NUL-terminated.
+     */
 #define GRUB_XEN_MAX_GUEST_CMDLINE 1024
     int8_t cmd_line[GRUB_XEN_MAX_GUEST_CMDLINE];
     /* The pfn range here covers both page table and p->m table frames.   */