diff options
author | 2018-10-11 16:17:38 -0700 | |
---|---|---|
committer | 2018-10-11 16:17:38 -0700 | |
commit | 229651a371ac590f47793cdacc8d28c0ac74bf48 (patch) | |
tree | 1e00e2d4caf2f3a0e954a2a0f45c951659f16c32 | |
parent | 2c47c953380d0a02df4bc7e4d7772b235cd7da9c (diff) |
Check range of value-typed channel arg
-rw-r--r-- | src/objective-c/GRPCClient/private/ChannelArgsUtil.m | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.m b/src/objective-c/GRPCClient/private/ChannelArgsUtil.m index 8ebf3a2659..04a5cc8345 100644 --- a/src/objective-c/GRPCClient/private/ChannelArgsUtil.m +++ b/src/objective-c/GRPCClient/private/ChannelArgsUtil.m @@ -21,6 +21,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/string_util.h> +#include <limits.h> + static void *copy_pointer_arg(void *p) { // Add ref count to the object when making copy id obj = (__bridge id)p; @@ -79,6 +81,11 @@ grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) { arg->type = GRPC_ARG_STRING; arg->value.string = gpr_strdup([value UTF8String]); } else if ([value respondsToSelector:@selector(intValue)]) { + if ([value compare:[NSNumber numberWithInteger:INT_MAX]] == NSOrderedDescending || + [value compare:[NSNumber numberWithInteger:INT_MIN]] == NSOrderedAscending) { + [NSException raise:NSInvalidArgumentException + format:@"Range exceeded for a value typed channel argument: %@", value]; + } arg->type = GRPC_ARG_INTEGER; arg->value.integer = [value intValue]; } else if (value != nil) { |