Reputation: 1381
I am using fmt.Scanf
to read a string input in Golang. But the command stalls when we pass in a large input (>1024 characters). I am using 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 fails https://pastebin.com/raw/fJ4QAZUZ
Go seems to take input till Jy
in that payload which marks 1024 number of characters. So is 1024 a limit or what?
PS - I had already tampered the encoded cookie at that link, so no worries.
Upvotes: 3
Views: 962
Reputation: 417612
It's not the limit of the fmt
package or fmt.Scanf()
, this example properly scans more than 3KB:
// 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
It's most likely the limit of your terminal. I also tried your unmodified version, pasted more than 10KB of text, and the result was 4096 bytes (Ubuntu linux 16.04, Bash).
Upvotes: 6