Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
5eba7971
Commit
5eba7971
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Switch from snprintf() to gpr_asprintf().
parent
0eb3e13e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/core/bad_client/tests/large_metadata.c
+25
-18
25 additions, 18 deletions
test/core/bad_client/tests/large_metadata.c
with
25 additions
and
18 deletions
test/core/bad_client/tests/large_metadata.c
+
25
−
18
View file @
5eba7971
...
...
@@ -33,10 +33,11 @@
#include
"test/core/bad_client/bad_client.h"
#include
<stdio.h>
#include
<string.h>
#include
<grpc/support/alloc.h>
#include
<grpc/support/string_util.h>
#include
"src/core/lib/support/string.h"
#include
"src/core/lib/surface/server.h"
#include
"test/core/end2end/cq_verifier.h"
...
...
@@ -64,23 +65,22 @@
// Each large-metadata header is constructed from these start and end
// strings, with a two-digit number in between.
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR \
"\x10\x0duser-header"
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR "\x10\x0duser-header"
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_END_STR \
"~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
// The size of each large-metadata header string.
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE \
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE
\
((sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR) - 1) + 2 + \
(sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_END_STR) - 1))
// The number of headers we're adding and the total size of the client
// payload.
#define NUM_HEADERS 95
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE \
((sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR) - 1) \
+
(NUM_HEADERS * PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE) + 1)
#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE
\
((sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR) - 1)
+
\
(NUM_HEADERS * PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE) + 1)
#define PFX_TOO_MUCH_METADATA_FROM_SERVER_STR \
"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
/* settings frame: sets \
...
...
@@ -217,19 +217,26 @@ int main(int argc, char **argv) {
grpc_test_init
(
argc
,
argv
);
// Test sending more metadata than the server will accept.
char
client_payload
[
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE
]
=
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR
;
size_t
offset
=
sizeof
(
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR
);
gpr_strvec
headers
;
gpr_strvec_init
(
&
headers
);
for
(
int
i
=
0
;
i
<
NUM_HEADERS
;
++
i
)
{
snprintf
(
client_payload
+
offset
,
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE
,
"%s%02d%s"
,
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR
,
i
,
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_END_STR
);
offset
+=
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE
;
char
*
str
;
gpr_asprintf
(
&
str
,
"%s%02d%s"
,
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_START_STR
,
i
,
PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_END_STR
);
gpr_strvec_add
(
&
headers
,
str
);
}
GRPC_RUN_BAD_CLIENT_TEST
(
server_verifier
,
client_validator
,
client_payload
,
0
);
size_t
headers_len
;
const
char
*
client_headers
=
gpr_strvec_flatten
(
&
headers
,
&
headers_len
);
gpr_strvec_destroy
(
&
headers
);
char
client_payload
[
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE
]
=
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR
;
memcpy
(
client_payload
+
sizeof
(
PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR
)
-
1
,
client_headers
,
headers_len
);
GRPC_RUN_BAD_CLIENT_TEST
(
server_verifier
,
client_validator
,
client_payload
,
0
);
gpr_free
((
void
*
)
client_headers
);
// Test sending more metadata than the client will accept.
GRPC_RUN_BAD_CLIENT_TEST
(
server_verifier_sends_too_much_metadata
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment