From 092aaf48702c04208be27944cc65c87c4e296a2b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 10:25:39 +0100 Subject: [PATCH] ax(ueps): rename tagLengthByte/tagLength to tagValueLength MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AX Principle 1 — the `Byte` suffix encodes storage type not semantics, and the intermediate `tagLength` variable was an immediate int cast of `tagLengthByte` with no additional meaning. Collapsed to a single `tagValueLength` variable that names what it is, not how it is stored. Co-Authored-By: Charon --- pkg/ueps/reader.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/ueps/reader.go b/pkg/ueps/reader.go index 185a1fc..6ea0972 100644 --- a/pkg/ueps/reader.go +++ b/pkg/ueps/reader.go @@ -47,13 +47,12 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er break } - tagLengthByte, err := reader.ReadByte() + tagValueLength, err := reader.ReadByte() if err != nil { return nil, err } - tagLength := int(tagLengthByte) - tagValue := make([]byte, tagLength) + tagValue := make([]byte, tagValueLength) if _, err := io.ReadFull(reader, tagValue); err != nil { return nil, err } @@ -62,34 +61,34 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er case TagVersion: header.Version = tagValue[0] signedData.WriteByte(tagByte) - signedData.WriteByte(byte(tagLength)) + signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagCurrentLayer: header.CurrentLayer = tagValue[0] signedData.WriteByte(tagByte) - signedData.WriteByte(byte(tagLength)) + signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagTargetLayer: header.TargetLayer = tagValue[0] signedData.WriteByte(tagByte) - signedData.WriteByte(byte(tagLength)) + signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagIntent: header.IntentID = tagValue[0] signedData.WriteByte(tagByte) - signedData.WriteByte(byte(tagLength)) + signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagThreatScore: header.ThreatScore = binary.BigEndian.Uint16(tagValue) signedData.WriteByte(tagByte) - signedData.WriteByte(byte(tagLength)) + signedData.WriteByte(tagValueLength) signedData.Write(tagValue) case TagHMAC: hmacSignature = tagValue default: // signedData.WriteByte(unknownTag); signedData.Write(tagValue) — unknown tags contribute to HMAC, blocking injection signedData.WriteByte(tagByte) - signedData.WriteByte(byte(tagLength)) + signedData.WriteByte(tagValueLength) signedData.Write(tagValue) } }