coreos / go-iptables

Go wrapper around iptables utility
Apache License 2.0
1.12k stars 256 forks source link

go-iptables throws panic #35

Closed sanbornm closed 7 years ago

sanbornm commented 7 years ago
2017/04/13 22:29:33 fork/exec /usr/sbin/iptables: cannot allocate memory
panic: interface conversion: error is *os.PathError, not *exec.ExitError

My Fix:

    if err := cmd.Run(); err != nil {
        switch err.(type) {
        default:
            return err
        case *exec.ExitError:
            return &Error{*(err.(*exec.ExitError)), stderr.String()}
        }
    }
lucab commented 7 years ago

Thanks for reporting! Yes I think that the unchecked typecast in runWithOutput() is a bit too aggressive and your typeswitch-with-default fixes it. Would you mind turning this inline snippet into a PR?