Skip to content

Commit

Permalink
golangci: Fix gosec aliasing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Aug 21, 2023
1 parent c503bc1 commit 0cefc46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions format/inet/flowsdecoder/flowsdecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type TCPDirection struct {
}

type TCPConnection struct {
Client TCPDirection
Server TCPDirection
Client *TCPDirection
Server *TCPDirection
tcpState *reassembly.TCPSimpleFSM
optChecker *reassembly.TCPOptionCheck
net gopacket.Flow
Expand Down Expand Up @@ -62,9 +62,9 @@ func (t *TCPConnection) ReassembledSG(sg reassembly.ScatterGather, ac reassembly
var d *TCPDirection
switch dir {
case reassembly.TCPDirClientToServer:
d = &t.Client
d = t.Client
case reassembly.TCPDirServerToClient:
d = &t.Server
d = t.Server
default:
panic("unreachable")
}
Expand Down Expand Up @@ -115,14 +115,14 @@ func (fd *Decoder) New(net, transport gopacket.Flow, tcp *layers.TCP, ac reassem
}

stream := &TCPConnection{
Client: TCPDirection{
Client: &TCPDirection{
Endpoint: TCPEndpoint{
IP: append([]byte(nil), net.Src().Raw()...),
Port: clientPort,
},
Buffer: &bytes.Buffer{},
},
Server: TCPDirection{
Server: &TCPDirection{
Endpoint: TCPEndpoint{
IP: append([]byte(nil), net.Dst().Raw()...),
Port: serverPort,
Expand Down
4 changes: 2 additions & 2 deletions format/pcap/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func fieldFlows(d *decode.D, fd *flowsdecoder.Decoder, tcpStreamFormat decode.Gr
var clientV any
var serverV any
d.FieldStruct("client", func(d *decode.D) {
clientV = f(d, &s.Client, format.TCP_Stream_In{
clientV = f(d, s.Client, format.TCP_Stream_In{
IsClient: true,
HasStart: s.Client.HasStart,
HasEnd: s.Client.HasEnd,
Expand All @@ -69,7 +69,7 @@ func fieldFlows(d *decode.D, fd *flowsdecoder.Decoder, tcpStreamFormat decode.Gr
})
})
d.FieldStruct("server", func(d *decode.D) {
serverV = f(d, &s.Server, format.TCP_Stream_In{
serverV = f(d, s.Server, format.TCP_Stream_In{
IsClient: false,
HasStart: s.Server.HasStart,
HasEnd: s.Server.HasEnd,
Expand Down
14 changes: 7 additions & 7 deletions format/riff/avi.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type idx1Sample struct {

type aviStream struct {
hasFormat bool
format decode.Group
format *decode.Group
formatInArg any
indexes []ranges.Range
ixSamples []ranges.Range
Expand Down Expand Up @@ -390,11 +390,11 @@ func aviDecode(d *decode.D) any {
format.BMPTagH264_UMSV,
format.BMPTagH264_tshd,
format.BMPTagH264_INMC:
s.format = aviMpegAVCAUGroup
s.format = &aviMpegAVCAUGroup
s.hasFormat = true
case format.BMPTagHEVC,
format.BMPTagHEVC_H265:
s.format = aviMpegHEVCAUGroup
s.format = &aviMpegHEVCAUGroup
s.hasFormat = true
}

Expand All @@ -417,11 +417,11 @@ func aviDecode(d *decode.D) any {

switch formatTag {
case format.WAVTagMP3:
s.format = aviMp3FrameGroup
s.format = &aviMp3FrameGroup
s.hasFormat = true
case format.WAVTagFLAC:
// TODO: can flac in avi have streaminfo somehow?
s.format = aviFLACFrameGroup
s.format = &aviFLACFrameGroup
s.hasFormat = true
}
case "iavs":
Expand Down Expand Up @@ -521,7 +521,7 @@ func aviDecode(d *decode.D) any {
index < len(streams) &&
streams[index].hasFormat:
s := streams[index]
d.FieldFormatLen("data", d.BitsLeft(), &s.format, s.formatInArg)
d.FieldFormatLen("data", d.BitsLeft(), s.format, s.formatInArg)
default:
d.FieldRawLen("data", d.BitsLeft())
}
Expand Down Expand Up @@ -559,7 +559,7 @@ func aviDecode(d *decode.D) any {
decodeSample := func(d *decode.D, sr ranges.Range) {
d.RangeFn(sr.Start, sr.Len, func(d *decode.D) {
if sr.Len > 0 && ai.DecodeSamples && s.hasFormat {
d.FieldFormat("sample", &s.format, s.formatInArg)
d.FieldFormat("sample", s.format, s.formatInArg)
} else {
d.FieldRawLen("sample", d.BitsLeft())
}
Expand Down

0 comments on commit 0cefc46

Please sign in to comment.