[service] Add check for kext command size

This commit is contained in:
Vladimir Stoilov
2024-06-28 13:20:18 +03:00
parent 176494550e
commit 4bf1736a83
6 changed files with 186 additions and 55 deletions

View File

@@ -5,11 +5,13 @@ package windowskext
import (
"context"
"errors"
"fmt"
"net"
"time"
"github.com/safing/portmaster/service/process"
"github.com/safing/portmaster/windows_kext/kextinterface"
"github.com/tevino/abool"
@@ -32,8 +34,15 @@ func (v *VersionInfo) String() string {
func Handler(ctx context.Context, packets chan packet.Packet, bandwidthUpdate chan *packet.BandwidthUpdate) {
for {
packetInfo, err := RecvVerdictRequest()
if errors.Is(err, kextinterface.ErrUnexpectedInfoSize) || errors.Is(err, kextinterface.ErrUnexpectedReadError) {
log.Criticalf("unexpected kext info data: %s", err)
continue // Depending on the info type this may not affect the functionality. Try to continue reading the next commands.
}
if err != nil {
log.Warningf("failed to get packet from windows kext: %s", err)
// Probably IO error, nothing else we can do.
return
}