]> Cypherpunks repositories - gostls13.git/commit
crypto/x509: continue to recognise MaxPathLen of zero as "no value".
authorAdam Langley <agl@golang.org>
Tue, 14 Oct 2014 01:35:53 +0000 (18:35 -0700)
committerAdam Langley <agl@golang.org>
Tue, 14 Oct 2014 01:35:53 +0000 (18:35 -0700)
commit64bed3f55fdf3628e0bfe75079a8f5f845aa7bb2
treedac15a4c65d98c887f4b9fb7b7781914af4d0153
parent73711533210a3ddc85e092eb06c1373277b65e99
crypto/x509: continue to recognise MaxPathLen of zero as "no value".

In [1] the behaviour of encoding/asn1 with respect to marshaling
optional integers was changed. Previously, a zero valued integer would
be omitted when marshaling. After the change, if a default value was
set then the integer would only be omitted if it was the default value.

This changed the behaviour of crypto/x509 because
Certificate.MaxPathLen has a default value of -1 and thus zero valued
MaxPathLens would no longer be omitted when marshaling. This is
arguably a bug-fix -- a value of zero for MaxPathLen is valid and
meaningful and now could be expressed. However it broke users
(including Docker) who were not setting MaxPathLen at all.

This change again causes a zero-valued MaxPathLen to be omitted and
introduces a ZeroMathPathLen member that indicates that, yes, one
really does want a zero. This is ugly, but we value not breaking users.

[1] https://code.google.com/p/go/source/detail?r=4218b3544610e8d9771b89126553177e32687adf

LGTM=rsc
R=rsc
CC=golang-codereviews, golang-dev
https://golang.org/cl/153420045
src/crypto/x509/x509.go
src/crypto/x509/x509_test.go