Skip to content

Commit

Permalink
Fix panic when cloning with wrong ssh format. (go-gitea#32076)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and GiteaBot committed Sep 24, 2024
1 parent d5d5fb1 commit dc7293c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ func runServ(c *cli.Context) error {
return nil
}

defer func() {
if err := recover(); err != nil {
_ = fail(ctx, "Internal Server Error", "Panic: %v\n%s", err, log.Stack(2))
}
}()

keys := strings.Split(c.Args().First(), "-")
if len(keys) != 2 || keys[0] != "key" {
return fail(ctx, "Key ID format error", "Invalid key argument: %s", c.Args().First())
Expand Down Expand Up @@ -189,10 +195,7 @@ func runServ(c *cli.Context) error {
}

verb := words[0]
repoPath := words[1]
if repoPath[0] == '/' {
repoPath = repoPath[1:]
}
repoPath := strings.TrimPrefix(words[1], "/")

var lfsVerb string
if verb == lfsAuthenticateVerb {
Expand Down

0 comments on commit dc7293c

Please sign in to comment.