Skip to content

Fix --host-command sending truncated payload on invalid byte#269

Closed
Copilot wants to merge 2 commits intohost-commandfrom
copilot/sub-pr-268
Closed

Fix --host-command sending truncated payload on invalid byte#269
Copilot wants to merge 2 commits intohost-commandfrom
copilot/sub-pr-268

Conversation

Copy link

Copilot AI commented Mar 2, 2026

When --host-command encountered an invalid payload byte, it breaked the parse loop but still returned Some((cmd_id, version, data)) — silently sending a truncated command instead of failing.

Changes

  • framework_lib/src/commandline/uefi.rs: Introduce a parse_error flag in the byte-parsing loop. On an invalid byte, set the flag and break; after the loop, return None if parse_error is set, making any malformed payload a hard parse failure.
// Before: truncated data silently sent
let mut data = Vec::new();
for j in (i + 3)..args.len() {
    ...
    } else {
        println!("Invalid data byte for --host-command: '{}'", args[j]);
        break; // still falls through to Some(...)
    }
}
Some((cmd_id, version, data))

// After: invalid byte aborts the command entirely
let mut parse_error = false;
for j in (i + 3)..args.len() {
    ...
    } else {
        println!("Invalid data byte for --host-command: '{}'", args[j]);
        parse_error = true;
        break;
    }
}
if parse_error { None } else { Some((cmd_id, version, data)) }

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: JohnAZoidberg <5307138+JohnAZoidberg@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on adding --host-command for raw EC host commands Fix --host-command sending truncated payload on invalid byte Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants