Skip to content

Small error in netProtoSplit in package net for DialIP #1130

@gopherbot

Description

@gopherbot

by jan.newmarch:

.

What steps will reproduce the problem?

Call DialIP("tc4", ....) without a ':' in the protocol

What is the expected output?

os.Error returned

What do you see instead?

panic: runtime error: slice bounds out of range

panic PC=0x1dd994
runtime.panic+0xa9 /home/local/go/src/pkg/runtime/proc.c:1019
    runtime.panic(0x0, 0x80aa310)
panicstring+0x61 /home/local/go/src/pkg/runtime/runtime.c:83
    panicstring(0x80aa310, 0x1d9858)
runtime.panicslice+0x27 /home/local/go/src/pkg/runtime/runtime.c:50
    runtime.panicslice()
runtime.slicestring+0x35 /home/local/go/src/pkg/runtime/string.c:204
    runtime.slicestring(0x808101f, 0x80f67e0, 0xffffffff, 0x0, 0x805e20d, ...)
net.netProtoSplit+0x105 /home/local/go/src/pkg/net/iprawsock.go:294
    net.netProtoSplit(0x8099504, 0x3, 0x0, 0xffffffff, 0x10, ...)
net.DialIP+0x4d /home/local/go/src/pkg/net/iprawsock.go:310
    net.DialIP(0x8099504, 0x3, 0x0, 0x0, 0x0, ...)
net.Dial+0x27a /home/local/go/src/pkg/net/dial.go:91
    net.Dial(0x8099504, 0x3, 0x0, 0x1da270, 0x0, ...)
main.main+0xd9 /home/httpd/html/go/socket/Ping.go:14
    main.main()
mainstart+0xf /home/local/go/src/pkg/runtime/386/asm.s:83
    mainstart()
goexit /home/local/go/src/pkg/runtime/proc.c:145
    goexit()


Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Linux newmarch-laptop 2.6.32-24-generic #41-Ubuntu SMP Thu Aug 19 01:12:52 UTC 2010 i686
GNU/Linux

Which revision are you using?  (hg identify)

6d3022dfb42b tip

Please provide any additional information below.

Func netProtoSplit in file iprawsock.go line 290 calls last() to locate the ':' in the
proto. Test if not there is in line 291. Test is wrong as last() counts DOWN not UP.
Should be "i == -1" not "i+1 >= len(netProto)"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions