From 3326539367dfa85cb2b0455d5b1c67eaaf59cf8e Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Wed, 18 Jan 2023 13:52:52 -0800 Subject: Fix threaded news bugs 1. Fix handling of article IDs sent as 4 bytes instead of 2 2. Fix incorrect article count listing that strangely only affects third party clients --- hotline/util.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 hotline/util.go (limited to 'hotline/util.go') diff --git a/hotline/util.go b/hotline/util.go new file mode 100644 index 0000000..d37feb5 --- /dev/null +++ b/hotline/util.go @@ -0,0 +1,17 @@ +package hotline + +import ( + "encoding/binary" + "errors" +) + +func byteToInt(bytes []byte) (int, error) { + switch len(bytes) { + case 2: + return int(binary.BigEndian.Uint16(bytes)), nil + case 4: + return int(binary.BigEndian.Uint32(bytes)), nil + } + + return 0, errors.New("unknown byte length") +} -- cgit