File: 0001-Fix-int-overflow-on-32bit.patch

package info (click to toggle)
golang-github-google-go-dap 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464 kB
  • sloc: sh: 19; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 1,564 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: Shengjing Zhu <zhsj@debian.org>
Date: Sun, 10 Jan 2021 23:08:56 +0800
Subject: Fix int overflow on 32bit

Forwarded: https://github.com/google/go-dap/pull/52
---
 io.go      | 4 ++--
 io_test.go | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/io.go b/io.go
index 5b85851..87125ef 100644
--- a/io.go
+++ b/io.go
@@ -95,7 +95,7 @@ func ReadBaseMessage(r *bufio.Reader) ([]byte, error) {
 // and required:
 // 		Content-Length: [0-9]+\r\n\r\n
 // Extracts and returns the content length.
-func readContentLengthHeader(r *bufio.Reader) (contentLength int, err error) {
+func readContentLengthHeader(r *bufio.Reader) (contentLength int64, err error) {
 	// Look for <some header>\r\n\r\n
 	headerWithCr, err := r.ReadString('\r')
 	if err != nil {
@@ -115,7 +115,7 @@ func readContentLengthHeader(r *bufio.Reader) (contentLength int, err error) {
 	if len(headerAndLength) < 2 {
 		return 0, ErrHeaderNotContentLength
 	}
-	return strconv.Atoi(headerAndLength[1])
+	return strconv.ParseInt(headerAndLength[1], 10, 64)
 }
 
 // WriteProtocolMessage encodes message and writes it to w.
diff --git a/io_test.go b/io_test.go
index 0c1a0fe..8c1b01e 100644
--- a/io_test.go
+++ b/io_test.go
@@ -90,7 +90,7 @@ func Test_readContentLengthHeader(t *testing.T) {
 	tests := []struct {
 		input         string
 		wantBytesLeft string // Bytes left in the reader after header reading
-		wantLen       int    // Extracted content length value
+		wantLen       int64  // Extracted content length value
 		wantErr       error
 	}{
 		{"", "", 0, io.EOF},