From d206b8c2bd313bf479131851c90651c4b356dc85 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Mon, 1 Apr 2019 21:53:37 +0200 Subject: [PATCH 1/5] Fix ParseDataBlock of unconfirmed data The Data slice was not initialized before calling copy(dst, src) --- data.go | 1 + 1 file changed, 1 insertion(+) diff --git a/data.go b/data.go index f2cc79b..2f3eacb 100644 --- a/data.go +++ b/data.go @@ -54,6 +54,7 @@ func ParseDataBlock(data []byte, dataType uint8, confirmed bool) (*DataBlock, er return nil, fmt.Errorf("dmr: block CRC error (%#04x != %#04x)", crc, db.CRC) } } else { + db.Data = make([]byte, db.Length) copy(db.Data, data[:db.Length]) } From f4fff4736580d76892987ceaef7c199d52624bb2 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Mon, 1 Apr 2019 21:54:59 +0200 Subject: [PATCH 2/5] Fix panic in Fragment.DataBlocks() duo to typo store vs stored --- data.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data.go b/data.go index 2f3eacb..049f812 100644 --- a/data.go +++ b/data.go @@ -164,7 +164,7 @@ func (df *DataFragment) DataBlocks(dataType uint8, confirm bool) ([]*DataBlock, store := int(block.Length) if df.Stored-stored < store { - store = df.Stored - store + store = df.Stored - stored } copy(block.Data, df.Data[stored:stored+store]) stored += store From d782d04296d6d5070c05b6d8057f1c98f0d671e2 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Mon, 1 Apr 2019 21:56:06 +0200 Subject: [PATCH 3/5] Fix serialization of SAP in DataHeader --- dataheader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataheader.go b/dataheader.go index c7ac1da..b990f17 100644 --- a/dataheader.go +++ b/dataheader.go @@ -222,7 +222,7 @@ func (h *DataHeader) Bytes() ([]byte, error) { if h.HeaderCompression { data[0] |= B00100000 } - data[1] = (h.ServiceAccessPoint & B00001111) + data[1] = (h.ServiceAccessPoint << 4) & B11110000 data[2] = uint8(h.DstID >> 16) data[3] = uint8(h.DstID >> 8) data[4] = uint8(h.DstID) From eacc75566e17447a0524817dc6e1c115467d1bb9 Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Mon, 15 Apr 2019 21:38:41 +0200 Subject: [PATCH 4/5] Fix test breaking due to vet checks Some incorrect fmt formatting strings broke tests due to vet checks being automatically applied since Go 1.10. --- controlblock.go | 2 +- dataheader.go | 2 +- dataheader_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controlblock.go b/controlblock.go index ad36a98..4dfe3fd 100644 --- a/controlblock.go +++ b/controlblock.go @@ -284,7 +284,7 @@ func ParseControlBlock(data []byte) (*ControlBlock, error) { cb.Data = &Preamble{} break default: - return nil, fmt.Errorf("dmr: unknown CSBK opcode %#02x (%#06b)", cb.Opcode, cb.Opcode) + return nil, fmt.Errorf("dmr: unknown CSBK opcode %02x (%06b)", cb.Opcode, cb.Opcode) } if err := cb.Data.Parse(data); err != nil { diff --git a/dataheader.go b/dataheader.go index b990f17..f0e0c5e 100644 --- a/dataheader.go +++ b/dataheader.go @@ -350,7 +350,7 @@ type ResponseData struct { } func (d ResponseData) String() string { - return fmt.Sprintf("response, blocks %d, type %s (%#02b %#03b), status %d", + return fmt.Sprintf("response, blocks %d, type %s (%02b %03b), status %d", d.BlocksToFollow, ResponseTypeName[d.ClassType], (d.ClassType >> 3), (d.ClassType & 0x07), d.Status) } diff --git a/dataheader_test.go b/dataheader_test.go index 19562a0..4e780f8 100644 --- a/dataheader_test.go +++ b/dataheader_test.go @@ -211,7 +211,7 @@ func TestDataHeaderShortDataDefined(t *testing.T) { t.Fatalf("decode failed: appended blocks wrong") case d.DDFormat != DDFormatUTF16: - t.Fatalf("decode failed: dd format wrong, expected UTF-16, got %d", DDFormatName[d.DDFormat]) + t.Fatalf("decode failed: dd format wrong, expected UTF-16, got %s", DDFormatName[d.DDFormat]) case d.Resync: t.Fatalf("decode failed: rsync bit wrong") From 9f086ae1821fc37552ef32487b8ddee740e63a6c Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Tue, 23 Apr 2019 17:26:09 +0200 Subject: [PATCH 5/5] Fix BM homebrew compatibility (rptrid comparison) BM switched from upper case to lower case hexadecimal representation in BrandMeister release 20190421-185653. The comparison must be case insensitive according to a member of the BM dev team (@cyanide-burnout) on Telegram: "it shoud check on case-insensetive way". --- homebrew/homebrew.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homebrew/homebrew.go b/homebrew/homebrew.go index 479c8ac..5a6f753 100644 --- a/homebrew/homebrew.go +++ b/homebrew/homebrew.go @@ -254,7 +254,8 @@ func (h *Homebrew) WriteToPeerWithID(b []byte, id uint32) error { } func (h *Homebrew) checkRepeaterID(id []byte) bool { - return id != nil && bytes.Equal(id, h.id) + // BrandMeister release 20190421-185653 switched from upper case to lower case hex digits + return id != nil && bytes.EqualFold(id, h.id) } func (h *Homebrew) getPeer(id uint32) *Peer {