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

Issue 1870047: code review 1870047: asn1 incorrectly encoding integers. When determining the

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 2 months ago by nwaples
Modified:
15 years, 2 months ago
Reviewers:
agl1
CC:
agl1, gri, golang-dev
Visibility:
Public.

Description

asn1 incorrectly encoding integers. When determining the encoded length it is not taking into account the sign bit. Fixes issue 997.

Patch Set 1 #

Patch Set 2 : code review 1870047: asn1 incorrectly encoding integers. When determining the #

Total comments: 2

Patch Set 3 : code review 1870047: asn1 incorrectly encoding integers. When determining the #

Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -3 lines) Patch
M src/pkg/asn1/marshal.go View 1 2 1 chunk +6 lines, -3 lines 0 comments Download
M src/pkg/asn1/marshal_test.go View 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 7
nwaples
Hello agl@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change.
15 years, 2 months ago (2010-08-06 01:42:00 UTC) #1
agl1
LGTM. Will land once I ask rsc what the deal with the CONTRIBUTORS file is ...
15 years, 2 months ago (2010-08-06 15:23:22 UTC) #2
gri
http://codereview.appspot.com/1870047/diff/2001/3001 File src/pkg/asn1/marshal.go (right): http://codereview.appspot.com/1870047/diff/2001/3001#newcode128 src/pkg/asn1/marshal.go:128: if i > 0 { This if is not ...
15 years, 2 months ago (2010-08-06 16:35:05 UTC) #3
nwaples
Hello agl1, gri (cc: golang-dev@googlegroups.com), I'd like you to review this change.
15 years, 2 months ago (2010-08-07 00:20:30 UTC) #4
agl1
*** Submitted as http://code.google.com/p/go/source/detail?r=123cc282ec65 *** asn1 incorrectly encoded signed integers. When determining the encoded length ...
15 years, 2 months ago (2010-08-09 14:26:08 UTC) #5
chressie
On Mon, Aug 9, 2010 at 4:26 PM, <agl@golang.org> wrote: > *** Submitted as > ...
15 years, 2 months ago (2010-08-09 15:03:00 UTC) #6
gri1
15 years, 2 months ago (2010-08-10 17:20:12 UTC) #7
This has been fixed in the meantiome: https://code.google.com/p/go/source/detail?r=16757c23fc3b715d75d34f25c72a16c4... Please abandon. Thanks. - gri On Thu, Aug 5, 2010 at 6:42 PM, <nwaples@gmail.com> wrote: > Reviewers: agl1, > > Message: > Hello agl@golang.org (cc: golang-dev@googlegroups.com), > > > I'd like you to review this change. > > > Description: > asn1 incorrectly encoding integers. When determining the > encoded length it is not taking into account the sign bit. > Fixes issue 997. > > Please review this at http://codereview.appspot.com/1870047/show > > Affected files: > > M src/pkg/asn1/marshal.go > M src/pkg/asn1/marshal_test.go > > > Index: src/pkg/asn1/marshal.go > =================================================================== > --- a/src/pkg/asn1/marshal.go > +++ b/src/pkg/asn1/marshal.go > @@ -123,13 +123,20 @@ > } > > func int64Length(i int64) (numBytes int) { > - if i == 0 { > - return 1 > + numBytes = 1 > + > + if i > 0 { > + for i > 127 { > + numBytes++ > + i >>= 8 > + } > } > > - for i > 0 { > - numBytes++ > - i >>= 8 > + if i < 0 { > + for i < -128 { > + numBytes++ > + i >>= 8 > + } > } > > return > Index: src/pkg/asn1/marshal_test.go > =================================================================== > --- a/src/pkg/asn1/marshal_test.go > +++ b/src/pkg/asn1/marshal_test.go > @@ -59,6 +59,10 @@ > > var marshalTests = []marshalTest{ > marshalTest{10, "02010a"}, > + marshalTest{127, "02017f"}, > + marshalTest{128, "02020080"}, > + marshalTest{-128, "020180"}, > + marshalTest{-129, "0202ff7f"}, > marshalTest{intStruct{64}, "3003020140"}, > marshalTest{twoIntStruct{64, 65}, "3006020140020141"}, > marshalTest{nestedStruct{intStruct{127}}, "3005300302017f"}, > > > 
Sign in to reply to this message.

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