Skip to content

Commit 8b7987b

Browse files
markmnlclaude
andcommitted
Test FlagHasPid with != 0, not == 1
Masking with a flag constant then comparing to 1 only works while the flag is bit 0; != 0 is correct for any bit position and matches every other flag check in the codebase. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 5779f14 commit 8b7987b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

cmd/fmsgd/host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ func readHeader(c net.Conn) (*FMsgHeader, *bufio.Reader, error) {
10181018
}
10191019

10201020
// read pid if any
1021-
if flags&FlagHasPid == 1 {
1021+
if flags&FlagHasPid != 0 {
10221022
pid, err := io.ReadAll(io.LimitReader(r, 32))
10231023
if err != nil {
10241024
return h, r, err

pkg/fmsg/fmsg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (h *Header) Encode() []byte {
9090
var b bytes.Buffer
9191
b.WriteByte(h.Version)
9292
b.WriteByte(h.Flags)
93-
if h.Flags&FlagHasPid == 1 {
93+
if h.Flags&FlagHasPid != 0 {
9494
b.Write(h.Pid[:])
9595
}
9696
str := h.From.ToString()

0 commit comments

Comments
 (0)