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

fuzz protocol to prevent panics and crashes #179

Open
huaguoping opened this issue Nov 21, 2016 · 7 comments
Open

fuzz protocol to prevent panics and crashes #179

huaguoping opened this issue Nov 21, 2016 · 7 comments

Comments

@huaguoping
Copy link

Hi, I am using valid connection information (e.g. valid ip, valid username, valid password ...) to run tsql.go.
However , I get the following panic:
panic: runtime error: slice bounds out of range

It happend when the processing was
"err = db.Ping()
if err != nil {
fmt.Println("Cannot connect: ", err.Error())
return
}"

Could anyone help me?Thank you very much! :)

@denisenkom
Copy link
Owner

Can you upload stack trace and/or logs?

@huaguoping
Copy link
Author

@denisenkom , Thank you for answer me :)

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0x1bfec0, 0xc42000c0f0)
/usr/local/Cellar/go/1.7/libexec/src/runtime/panic.go:500 +0x1a1
github.com/denisenkom/go-mssqldb.(*tdsBuffer).readNextPacket(0xc420010b40, 0x5, 0xc42000cdf5)
/Users/huaguoping/goyard/smm/src/github.com/denisenkom/go-mssqldb/buf.go:108 +0x295
github.com/denisenkom/go-mssqldb.(*tdsBuffer).BeginRead(0xc420010b40, 0xc42000cdfa, 0xc42000cdf5, 0x5)
/Users/huaguoping/goyard/smm/src/github.com/denisenkom/go-mssqldb/buf.go:120 +0x2b
github.com/denisenkom/go-mssqldb.readPrelogin(0xc420010b40, 0xc420014900, 0x0, 0x0)
/Users/huaguoping/goyard/smm/src/github.com/denisenkom/go-mssqldb/tds.go:197 +0x40
github.com/denisenkom/go-mssqldb.connect(0xc4200147e0, 0x0, 0x0, 0x0)
/Users/huaguoping/goyard/smm/src/github.com/denisenkom/go-mssqldb/tds.go:913 +0x67d
github.com/denisenkom/go-mssqldb.openConnection(0x1fd2d1, 0x95, 0xc4200147e0, 0xc41ffdeffa, 0x0, 0x46e000)
/Users/huaguoping/goyard/smm/src/github.com/denisenkom/go-mssqldb/mssql.go:144 +0x40
github.com/denisenkom/go-mssqldb.(*MssqlDriver).Open(0xc42002a178, 0x1fd2d1, 0x95, 0x1e8920, 0x3c7601, 0x1000000000000, 0xa8)
/Users/huaguoping/goyard/smm/src/github.com/denisenkom/go-mssqldb/mssql.go:134 +0x5b
database/sql.(*DB).conn(0xc420420000, 0xc420018501, 0x10, 0x10, 0xa0)
/usr/local/Cellar/go/1.7/libexec/src/database/sql/sql.go:824 +0x24e
database/sql.(*DB).Ping(0xc420420000, 0x5, 0x1fd2d1)
/usr/local/Cellar/go/1.7/libexec/src/database/sql/sql.go:503 +0x34
main.main()
/Users/huaguoping/huaguoping/tmp/main/test_sqlserver2.go:23 +0xb0
exit status 2

@denisenkom
Copy link
Owner

I think you probably specified incorrect port number. Looks like go-mssqldb tried to read from provided port but the data that was read was unexpected. This could happen if the port that go-mssqldb is talking to is not MSSQL server but something else.

@huaguoping
Copy link
Author

Oh, my fault!! I used port 3306.
Now I am trying use 1433. Thank You very much!! 👍

But I get another error....

Login error: read tcp localhost:53738->sqlserver:1433: read: connection reset by peer

@denisenkom
Copy link
Owner

Do you have a stack trace?

@huaguoping
Copy link
Author

Thank you for your patience... :)

Cannot connect: Login error: read tcp localhost:54318-> sqlserver:1433: read: connection reset by peer
panic: Login error: read tcp localhost:54319-> sqlserver:1433: read: connection reset by peer

goroutine 1 [running]:
panic(0x1bd200, 0xc42046cae0)
/usr/local/Cellar/go/1.7/libexec/src/runtime/panic.go:500 +0x1a1
main.main()
/Users/huaguoping/huaguoping/tmp/main/test_sqlserver2.go:35 +0x6bb
exit status 2

@denisenkom
Copy link
Owner

No problem.

This stack trace doesn't look very useful. You can try to enable logging, see https://github.com/denisenkom/go-mssqldb#connection-parameters for instructions. You can also look at SQL server logs, it might have something useful there.

@kardianos kardianos changed the title panic fuzz protocol to prevent panics and crashes Dec 4, 2016
gabrielcorado pushed a commit to gravitational/go-mssqldb that referenced this issue Oct 4, 2024
* preserve type information for Valuer parameters

* support uniqueidentifier in AE

* update readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants