Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic with bad .gitmodules file #2677

Closed
gramakri opened this Issue Feb 22, 2016 · 6 comments

Comments

2 participants
@gramakri
Copy link
Contributor

gramakri commented Feb 22, 2016

Please take a moment to search that an issue doesn't already exist.

For bug reports, please give the relevant info:

  • Gogs version (or commit ref): 0.8.25
  • Git version: 2.5.0
  • Operating system: Cloudron
  • Database:
    • PostgreSQL
    • [ X ] MySQL
    • SQLite
  • Log gist:
20:53:10 [main] [Macaron] PANIC: runtime error: slice bounds out of range
20:53:10 [main] /usr/local/go/src/runtime/panic.go:423 (0x433d89)
20:53:10 [main] /usr/local/go/src/text/template/exec.go:100 (0x50e71b)
20:53:10 [main] /usr/local/go/src/runtime/asm_amd64.s:437 (0x46512e)
20:53:10 [main] /usr/local/go/src/runtime/panic.go:423 (0x433d89)
20:53:10 [main] /usr/local/go/src/runtime/panic.go:18 (0x4322c9)
20:53:10 [main] /home/vagrant/go/src/github.com/gogits/git-module/submodule.go:54 (0x81e1c5)
20:53:10 [main] /usr/local/go/src/runtime/asm_amd64.s:438 (0x4651ce)
20:53:10 [main] /usr/local/go/src/reflect/value.go:432 (0x928caa)
20:53:10 [main] /usr/local/go/src/reflect/value.go:300 (0x927971)

Description

Gogs has a PANIC when loading repositories with bad .gitmodules. See https://git.girish.in/hacks/xembedoffscreen.

The .gitmodules files in the repo has the following content. The url is not valid (the server doesn't exist anymore).

[submodule "npploader"]
    path = npploader
    url = git+ssh://git@git.forwardbias.in/npploader.git

...

@gramakri

This comment has been minimized.

Copy link
Contributor Author

gramakri commented Feb 22, 2016

You can get hold of the repo by

git clone ssh://git@git.girish.in:29418/hacks/xembedoffscreen

Reset to version af62a661f7b1e60d48276b2b4b7d149c81fd357c (HEAD commit fixes the issue by changing the .gitmodules file)

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Feb 22, 2016

Thanks your feedback!

Maybe this is same as #1926?

@gramakri

This comment has been minimized.

Copy link
Contributor Author

gramakri commented Feb 22, 2016

@Unknwon From the code at https://github.com/gogits/git-module/blob/e092efdab2c2e03bcda02f8d838fa829ac4b64e3/submodule.go#L50, the issue is reproduced as:

    url := "git+ssh://git@git.forwardbias.in/npploader.git"
    i := strings.Index(url, "@")
    j := strings.LastIndex(url, ":")

    fmt.Println("Hello, playground", url[i+1:j])

Maybe a hotfix is to change https://github.com/gogits/git-module/blob/e092efdab2c2e03bcda02f8d838fa829ac4b64e3/submodule.go#L52 to have ``&& i < j`.

Unknwon added a commit to gogs/git-module that referenced this issue Feb 22, 2016

@Unknwon Unknwon added the kind/bug label Feb 22, 2016

@Unknwon Unknwon added this to the 0.9.0 milestone Feb 22, 2016

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Feb 22, 2016

Code pushed, please do go get -u github.com/gogits/git-module and recompile Gogs.

@gramakri

This comment has been minimized.

Copy link
Contributor Author

gramakri commented Feb 22, 2016

Seems to work, thanks!

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Feb 22, 2016

👍

ethantkoenig pushed a commit to ethantkoenig/gogs that referenced this issue Oct 13, 2017

Backport of migration fixes (gogs#2604) (gogs#2677)
* Rewrite migrations to not depend on future code changes (gogs#2604)

* v38 migration used an outdated version of RepoUnit model (gogs#2602)

* change repoUnit model in migration

* fix v16 migration repo_unit table

* fix lint error

* move type definition inside function

* Fix migration from Gogs

* Refactor code

* add error check

* Additiomal fixes for migrations

* Add back nil check

* replace deprecated .Id with .ID

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* change string map to interface map

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.