From 67920ccbdd3425e469a4052d7331603fad229054 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 30 Mar 2026 13:43:08 +0900 Subject: [PATCH] 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. --- curl.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/curl.go b/curl.go index d3d6e83..927d4a3 100644 --- a/curl.go +++ b/curl.go @@ -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)