Skip to content

crypto/tls: Conn#Read blocks on zero length slice argument #7775

Description

@gopherbot

by aalevy:

What does 'go version' print?

go version devel +b3405f9c2e32 Sat Apr 12 14:56:17 2014 +1000 + linux/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

Example sources files at https://gist.github.com/alevy/10606796

1. Generate a certificate (self signed or otherwise)
1. Run server_net.go and connect from telnet over port 8080
2. Run server_tls.go and connect via openssl s_client -connect localhost:8080

What happened?
net.Conn#Read returns immeidately since the buffer passed in as an argument is
zero-length (and the read Syscall returns 0 on a 0 length buffer), while tls.Conn#Read
blocks until there is some data to read even though the buffer is 0-length 

What should have happened instead?
The behavior should have been the same for both -- either block for both (unreasonable
since the read syscall won't block), or don't block in the tls version.

Please provide any additional information below.
This is easy to accomplish by sticking a check for the length at the beginning of
tls.Conn#Read (and I have a patch ready for this), but not sure this is the best place
to do it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions