fix(app): reject malformed daemon error replies
- commit
- ca64e93055b87d8219f727cd41109065d2ee128b
- author
- brice · · 2026-08-28 08:45 UTC
- committer
- brice · · 2026-08-28 14:56 UTC
- parent
- 6632680
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +6 -3
M internal/app/run.go +4 -1
| @@ -1612,7 +1612,10 @@ func runKill(ctx context.Context, name string, all, daemon bool) (retErr error) | |||
| 1612 | 1612 | return fmt.Errorf("vev: reading kill reply: %w", err) | |
| 1613 | 1613 | } | |
| 1614 | 1614 | if reply.Type == wire.MsgError { | |
| 1615 | - | em, _ := wire.UnmarshalErrorMsg(reply.Payload) | |
| 1615 | + | em, err := wire.UnmarshalErrorMsg(reply.Payload) | |
| 1616 | + | if err != nil { | |
| 1617 | + | return fmt.Errorf("vev: decoding error reply: %w", err) | |
| 1618 | + | } | |
| 1616 | 1619 | return fmt.Errorf("vev: %s", em.Text) | |
| 1617 | 1620 | } | |
| 1618 | 1621 | printKillSuccess(name, all, daemon) | |
| @@ -1612,7 +1612,10 @@ func runKill(ctx context.Context, name string, all, daemon bool) (retErr error) | |||||
| 1612 | return fmt.Errorf("vev: reading kill reply: %w", err) | 1612 | return fmt.Errorf("vev: reading kill reply: %w", err) | ||
| 1613 | } | 1613 | } | ||
| 1614 | if reply.Type == wire.MsgError { | 1614 | if reply.Type == wire.MsgError { | ||
| 1615 | - | em, _ := wire.UnmarshalErrorMsg(reply.Payload) | 1615 | + | em, err := wire.UnmarshalErrorMsg(reply.Payload) |
| 1616 | + | if err != nil { | |||
| 1617 | + | return fmt.Errorf("vev: decoding error reply: %w", err) | |||
| 1618 | + | } | |||
| 1616 | return fmt.Errorf("vev: %s", em.Text) | 1619 | return fmt.Errorf("vev: %s", em.Text) | ||
| 1617 | } | 1620 | } | ||
| 1618 | printKillSuccess(name, all, daemon) | 1621 | printKillSuccess(name, all, daemon) | ||
M internal/usecase/daemon/durable_recovery_test.go +2 -2
| @@ -886,7 +886,7 @@ func TestRestoreCancellationTransitionsBeforeAttachCompletion(t *testing.T) { | |||
| 886 | 886 | ||
| 887 | 887 | attached := make(chan error, 1) | |
| 888 | 888 | go func() { | |
| 889 | - | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name}, nil) | |
| 889 | + | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name, Size: domain.Size{Cols: 80, Rows: 24}}, nil) | |
| 890 | 890 | attached <- err | |
| 891 | 891 | }() | |
| 892 | 892 | cancelRestore() | |
| @@ -963,7 +963,7 @@ func TestAttachRejectsDegraded(t *testing.T) { | |||
| 963 | 963 | d.serveCtx, d.serveCancel = context.WithCancel(context.Background()) | |
| 964 | 964 | defer d.serveCancel() | |
| 965 | 965 | ||
| 966 | - | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name}, nil) | |
| 966 | + | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name, Size: domain.Size{Cols: 80, Rows: 24}}, nil) | |
| 967 | 967 | var protocolError *protoErr | |
| 968 | 968 | require.ErrorAs(t, err, &protocolError) | |
| 969 | 969 | require.Equal(t, protocol.ErrInternal, protocolError.code) | |
| @@ -886,7 +886,7 @@ func TestRestoreCancellationTransitionsBeforeAttachCompletion(t *testing.T) { | |||||
| 886 | 886 | ||||
| 887 | attached := make(chan error, 1) | 887 | attached := make(chan error, 1) | ||
| 888 | go func() { | 888 | go func() { | ||
| 889 | - | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name}, nil) | 889 | + | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name, Size: domain.Size{Cols: 80, Rows: 24}}, nil) |
| 890 | attached <- err | 890 | attached <- err | ||
| 891 | }() | 891 | }() | ||
| 892 | cancelRestore() | 892 | cancelRestore() | ||
| @@ -963,7 +963,7 @@ func TestAttachRejectsDegraded(t *testing.T) { | |||||
| 963 | d.serveCtx, d.serveCancel = context.WithCancel(context.Background()) | 963 | d.serveCtx, d.serveCancel = context.WithCancel(context.Background()) | ||
| 964 | defer d.serveCancel() | 964 | defer d.serveCancel() | ||
| 965 | 965 | ||||
| 966 | - | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name}, nil) | 966 | + | _, _, err := d.route(protocol.Hello{Version: protocol.Version, Intent: protocol.IntentAttach, Name: record.Name, Size: domain.Size{Cols: 80, Rows: 24}}, nil) |
| 967 | var protocolError *protoErr | 967 | var protocolError *protoErr | ||
| 968 | require.ErrorAs(t, err, &protocolError) | 968 | require.ErrorAs(t, err, &protocolError) | ||
| 969 | require.Equal(t, protocol.ErrInternal, protocolError.code) | 969 | require.Equal(t, protocol.ErrInternal, protocolError.code) | ||