fix: prevent out-of-bounds panic in curl flag parsing

When a flag expecting a value (e.g. --sec) is the last argument,
the code incremented the index without checking if the next
argument exists, causing a potential panic on os.Args access.
This commit is contained in:
Yasuhiro Matsumoto
2026-03-30 13:43:08 +09:00
parent f59c8a670d
commit 67920ccbdd

View File

@@ -120,8 +120,10 @@ func realCurl() error {
keyFlags = append(keyFlags, arg)
if arg != "--prompt-sec" {
i++
val := os.Args[i+2]
keyFlags = append(keyFlags, val)
if i+2 >= len(os.Args) {
break
}
keyFlags = append(keyFlags, os.Args[i+2])
}
} else {
curlFlags = append(curlFlags, arg)