Skip to content

roachpb: Prohibit access to NoopRequest.Header()#11919

Merged
bdarnell merged 3 commits intocockroachdb:masterfrom
bdarnell:noop
Dec 6, 2016
Merged

roachpb: Prohibit access to NoopRequest.Header()#11919
bdarnell merged 3 commits intocockroachdb:masterfrom
bdarnell:noop

Conversation

@bdarnell
Copy link
Copy Markdown
Contributor

@bdarnell bdarnell commented Dec 3, 2016

Add explicit type checks to guard against inappropriate access.

Fixes #11195


This change is Reviewable

@tamird
Copy link
Copy Markdown
Contributor

tamird commented Dec 3, 2016

Reviewed 7 of 7 files at r1, 4 of 4 files at r2, 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks broke.


pkg/kv/batch_test.go, line 102 at r3 (raw file):

			t.Errorf("got %s, expected %s", rk, leftKey)
		}
		rk, err = prev(ba, leftKey)

looks like something got truncated here, and there's a spurious empty line below


pkg/roachpb/gen_batch.go, line 54 at r1 (raw file):

		field := t.Field(i).Name
		info.name = field
		// The ResponseUnion fields match those in RequestUnion, with one exception.

"the following exceptions:" so the next person doesn't have to edit this again


Comments from Reviewable

@tamird
Copy link
Copy Markdown
Contributor

tamird commented Dec 3, 2016

:lgtm:


Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks broke.


Comments from Reviewable

@bdarnell
Copy link
Copy Markdown
Contributor Author

bdarnell commented Dec 4, 2016

Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks broke.


pkg/kv/batch_test.go, line 102 at r3 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

looks like something got truncated here, and there's a spurious empty line below

Removed this line and the blank one


pkg/roachpb/gen_batch.go, line 54 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

"the following exceptions:" so the next person doesn't have to edit this again

Done.


Comments from Reviewable

@tamird
Copy link
Copy Markdown
Contributor

tamird commented Dec 4, 2016

Reviewed 1 of 7 files at r4, 4 of 4 files at r5, 2 of 2 files at r6.
Review status: :shipit: all files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from Reviewable

Restore the header fields to deprecated requests and responses instead
of embedding a NoopRequest (partially reverting cockroachdb#9362). NoopRequests do
not have keys, but never appear alone, ensuring that the batch as a
whole has at least one request with keys. Deprecated requests, however,
can appear alone and therefore must have keys to allow other invariants
to be validated.
Guard all (tested) accesses to Request.Header with explicit checks for
NoopRequest.
@bdarnell bdarnell merged commit 5395a62 into cockroachdb:master Dec 6, 2016
@bdarnell bdarnell deleted the noop branch December 6, 2016 03:29
bdarnell added a commit to bdarnell/cockroach that referenced this pull request Dec 14, 2016
The roachpb.Method type is sometimes a convenient shorthand for
referring to different kinds of roachpb.Requests, but where it matters
we always use type switches. The Method of a request has occasionally
diverged from its type, leading to problems as in cockroachdb#11919.

Additionally, as a part of cleaning up cockroachdb#10084, I'm about to introduce a
new type storage.Command which makes roachpb.Method feel redundant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants