-
Notifications
You must be signed in to change notification settings - Fork 73
Harden Pairs de/serialization. #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
88993b8
Harden Pairs de/serialization.
PiotrSikora 1ede63d
review: add --unwindlib=libgcc.
PiotrSikora 9dec346
review: avoid using templates.
PiotrSikora dc90a09
review: fix clang-tidy errors.
PiotrSikora c0788fa
review: don't build fuzzers on Windows.
PiotrSikora f3d76d6
review: fix syntax.
PiotrSikora d5b2dde
review: fix syntax, maybe.
PiotrSikora bd4c626
review: don't run fuzzers in cross-compiled builds.
PiotrSikora 35ea3e3
review: add Mike's comment.
PiotrSikora 9266678
Merge branch 'master' into PiotrSikora/sec-003
PiotrSikora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2016-2019 Envoy Project Authors | ||
// Copyright 2020 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <string_view> | ||
#include <vector> | ||
|
||
namespace proxy_wasm { | ||
|
||
using Pairs = std::vector<std::pair<std::string_view, std::string_view>>; | ||
using StringPairs = std::vector<std::pair<std::string, std::string>>; | ||
|
||
class PairsUtil { | ||
public: | ||
/** | ||
* pairsSize returns the buffer size required to serialize Pairs. | ||
* @param pairs Pairs to serialize. | ||
* @return size of the output buffer. | ||
*/ | ||
static size_t pairsSize(const Pairs &pairs); | ||
|
||
static size_t pairsSize(const StringPairs &stringpairs) { | ||
Pairs views(stringpairs.begin(), stringpairs.end()); | ||
return pairsSize(views); | ||
} | ||
|
||
/** | ||
* marshalPairs serializes Pairs to output buffer. | ||
* @param pairs Pairs to serialize. | ||
* @param buffer output buffer. | ||
* @param size size of the output buffer. | ||
* @return indicates whether serialization succeeded or not. | ||
*/ | ||
static bool marshalPairs(const Pairs &pairs, char *buffer, size_t size); | ||
|
||
static bool marshalPairs(const StringPairs &stringpairs, char *buffer, size_t size) { | ||
Pairs views(stringpairs.begin(), stringpairs.end()); | ||
return marshalPairs(views, buffer, size); | ||
} | ||
|
||
/** | ||
* toPairs deserializes input buffer to Pairs. | ||
* @param buffer serialized input buffer. | ||
* @return deserialized Pairs. | ||
*/ | ||
static Pairs toPairs(std::string_view buffer); | ||
}; | ||
|
||
} // namespace proxy_wasm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.