Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1350)

Issue 6497105: crypto/rand: test zero len read does not fail (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by dave
Modified:
11 years, 8 months ago
Reviewers:
brainman
Visibility:
Public.

Description

crypto/rand: test zero len read does not fail

Patch Set 1 #

Patch Set 2 : diff -r 95fb3bcdc941 https://code.google.com/p/go #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -0 lines) Patch
M src/pkg/crypto/rand/rand_test.go View 1 1 chunk +11 lines, -0 lines 1 comment Download

Messages

Total messages: 1
brainman
11 years, 8 months ago (2012-09-10 00:07:40 UTC) #1
Your new test fail:

C:\>test -test.v
=== RUN TestRead
--- PASS: TestRead (0.80 seconds)
=== RUN TestReadEmpty
--- PASS: TestReadEmpty (0.00 seconds)
panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range

goroutine 4 [running]:
testing.func-+003(0x30e747d4, 0x30e73900)
        /root/go/root/src/pkg/testing/testing.go:292 +0x12b
----- stack segment boundary -----
crypto/rand.(*rngReader).Read(0x10e6a0d0, 0x59ee20, 0x0, 0x0, 0x0, ...)
        /root/go/root/src/pkg/crypto/rand/rand_windows.go:38 +0x2a8
crypto/rand.TestReadEmpty(0x10e6fd20, 0xe)
        /root/go/root/src/pkg/crypto/rand/rand_test.go:35 +0x69
testing.tRunner(0x10e6fd20, 0x59b02c, 0x0)
        /root/go/root/src/pkg/testing/testing.go:297 +0x70
created by testing.RunTests
        /root/go/root/src/pkg/testing/testing.go:373 +0x781

goroutine 1 [chan receive]:
testing.RunTests(0x401000, 0x59b020, 0x2, 0x2, 0x30e71701, ...)
        /root/go/root/src/pkg/testing/testing.go:374 +0x7bf
testing.Main(0x401000, 0x59b020, 0x2, 0x2, 0x59ea28, ...)
        /root/go/root/src/pkg/testing/testing.go:309 +0x68
main.main()
        crypto/rand/_test/_testmain.go:49 +0x80

goroutine 2 [syscall]:
created by runtime.main
        /root/go/root/src/pkg/runtime/proc.c:220

C:\>

You should fix rand_windows.go. Just check slice length an bail out if zero.

Alex

http://codereview.appspot.com/6497105/diff/1001/src/pkg/crypto/rand/rand_test.go
File src/pkg/crypto/rand/rand_test.go (right):

http://codereview.appspot.com/6497105/diff/1001/src/pkg/crypto/rand/rand_test...
src/pkg/crypto/rand/rand_test.go:41: t.Fatalf("Read(make(nil) = %d, %v", n, err)
s/make(//
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b