Add logging code for out-of-bounds buffer addresses
This commit is contained in:
1 parent
123df70716
commit
f01cf72d6d
1 file changed
+13
+13
@@ -6,7 +6,9 @@ package go3270
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Response encapsulates data received from a 3270 client in response to the
|
// Response encapsulates data received from a 3270 client in response to the
|
||||||
@@ -210,6 +212,17 @@ func handleField(addr int, value []byte, fm fieldmap, values map[string]string)
|
|||||||
// decodeBufAddr decodes a raw 2-byte encoded buffer address and returns the
|
// decodeBufAddr decodes a raw 2-byte encoded buffer address and returns the
|
||||||
// integer value of the address (i.e. 0-1919)
|
// integer value of the address (i.e. 0-1919)
|
||||||
func decodeBufAddr(raw [2]byte) int {
|
func decodeBufAddr(raw [2]byte) int {
|
||||||
|
if decodes[raw[0]]<<6 > 254 {
|
||||||
|
fmt.Fprintf(os.Stderr,
|
||||||
|
"UNEXPECTED VALUE: decodeBufAddr got raw value of %02x %02x\n",
|
||||||
|
raw[0], raw[1])
|
||||||
|
}
|
||||||
|
if decodes[raw[1]] > 254 {
|
||||||
|
fmt.Fprintf(os.Stderr,
|
||||||
|
"UNEXPECTED VALUE: decodeBufAddr got raw value of %02x %02x\n",
|
||||||
|
raw[0], raw[1])
|
||||||
|
}
|
||||||
|
|
||||||
hi := decodes[raw[0]] << 6
|
hi := decodes[raw[0]] << 6
|
||||||
lo := decodes[raw[1]]
|
lo := decodes[raw[1]]
|
||||||
return hi | lo
|
return hi | lo
|
||||||
|
|||||||
Reference in new issue
Block a user