Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Added checking of arg length to avoid panics when parsing in snapctl.
Browse files Browse the repository at this point in the history
  • Loading branch information
IRCody committed Feb 18, 2016
1 parent be26613 commit 774c42e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions cmd/snapctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,31 @@ func init() {
for idx, a := range os.Args {
switch a {
case "--url":
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
url = *prtURL
if len(os.Args) >= idx+2 {
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
url = *prtURL
}
}
case "-u":
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
url = *prtU
if len(os.Args) >= idx+2 {
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
url = *prtU
}
}
case "--api-version":
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
ver = *prtAv
if len(os.Args) >= idx+2 {
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
ver = *prtAv
}
}
case "-a":
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
ver = *prtA
if len(os.Args) >= idx+2 {
if err := f1.Parse(os.Args[idx : idx+2]); err == nil {
ver = *prtA
}
}
case "--insecure":
if err := f1.Parse(os.Args[idx:]); err == nil {
if err := f1.Parse([]string{os.Args[idx]}); err == nil {
secure = *prti
}
}
Expand Down

0 comments on commit 774c42e

Please sign in to comment.