aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/compression
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2015-07-21 16:22:58 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2015-07-21 16:22:58 -0700
commit1c604fd4f54e0e5744a357818c1782ff7877844e (patch)
tree22b7a83a7ed42288492685f4b37bce7539e66b1c /src/core/compression
parentc0a09015b17d8db1ea6bee0cba5d868c7f6f6fca (diff)
Fixed buggy grpc_compression_algorithm_parse
Diffstat (limited to 'src/core/compression')
-rw-r--r--src/core/compression/algorithm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/compression/algorithm.c b/src/core/compression/algorithm.c
index 8a60b4ef48..077647ebe1 100644
--- a/src/core/compression/algorithm.c
+++ b/src/core/compression/algorithm.c
@@ -35,17 +35,17 @@
#include <string.h>
#include <grpc/compression.h>
-int grpc_compression_algorithm_parse(const char* name,
+int grpc_compression_algorithm_parse(const char* name, size_t name_length,
grpc_compression_algorithm *algorithm) {
/* we use strncmp not only because it's safer (even though in this case it
* doesn't matter, given that we are comparing against string literals, but
* because this way we needn't have "name" nil-terminated (useful for slice
* data, for example) */
- if (strncmp(name, "none", 4) == 0) {
+ if (strncmp(name, "none", name_length) == 0) {
*algorithm = GRPC_COMPRESS_NONE;
- } else if (strncmp(name, "gzip", 4) == 0) {
+ } else if (strncmp(name, "gzip", name_length) == 0) {
*algorithm = GRPC_COMPRESS_GZIP;
- } else if (strncmp(name, "deflate", 7) == 0) {
+ } else if (strncmp(name, "deflate", name_length) == 0) {
*algorithm = GRPC_COMPRESS_DEFLATE;
} else {
return 0;