Skip to content

Commit

Permalink
vm: Limit size of descriptions
Browse files Browse the repository at this point in the history
Descriptions longer than about 128KiB will crash the Cockpit session
with a protocol error since they are included in the open message for
a "spawn" channel.

Only use the first 32k (about) when setting them to avoid that.

Fixes cockpit-project#1889
  • Loading branch information
mvollmer committed Nov 11, 2024
1 parent 361d3aa commit 9fa9ffb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libvirtApi/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@ async function domainSetXML(vm, option, values) {
}

export async function domainSetDescription(vm, description) {
// The description will appear in a "open" message for a "spawn"
// channel, and excessive lengths will crash the session with a
// protocol error. So let's limit it to a reasonable length here.
if (description.length > 32000)
description = description.slice(0, 32000);
await domainSetXML(vm, "metadata", { description });
}

Expand Down

0 comments on commit 9fa9ffb

Please sign in to comment.