Failed to read input more than 1024 characters in Go
I am using fmt.Scanf
to read input line in Golang. But the command stops when we pass in a large input (> 1024 characters). I am using the Go version go1.8.3 darwin/amd64
.
Here is the code
package main
import "fmt"
func main() {
var s string
fmt.Scanf("%s", &s)
fmt.Println(s)
}
Here is the payload that is failing https://pastebin.com/raw/fJ4QAZUZ
Go seems to accept input before Jy
in this payload, which marks 1,024 characters. So what's the 1024 limit or what?
PS - I've already spoofed the encoded cookie on this link, so don't worry.
source to share
This is not the limit fmt
or fmt.Scanf()
, this example scans more than 3KB correctly:
// src is a looooong text (>3KB)
var s string
fmt.Println(len(src))
fmt.Sscanf(src, "%s", &s)
fmt.Println(len(s))
Try it on the Go Playground
This is most likely the limit of your terminal. I also tried your unmodified version, pasting over 10KB of text and the result was 4096 bytes (Ubuntu linux 16.04, Bash).
source to share