Skip to content
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

header handling: prevent nil header value crashes in obj-c #1826

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions library/objective-c/EnvoyBridgeUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,17 @@ static inline EnvoyHeaders *to_ios_headers(envoy_headers headers) {
NSString *headerValue = [[NSString alloc] initWithBytes:header.value.bytes
length:header.value.length
encoding:NSUTF8StringEncoding];
// Ensure list is present in dictionary value
NSMutableArray *headerValueList = headerDict[headerKey];
if (headerValueList == nil) {
headerValueList = [NSMutableArray new];
headerDict[headerKey] = headerValueList;
// TODO: https://github.com/envoyproxy/envoy-mobile/issues/1825. All header values passed in
// here should be valid.
if (headerKey != nil && headerValue != nil) {
// Ensure list is present in dictionary value
NSMutableArray *headerValueList = headerDict[headerKey];
if (headerValueList == nil) {
headerValueList = [NSMutableArray new];
headerDict[headerKey] = headerValueList;
}
[headerValueList addObject:headerValue];
}
[headerValueList addObject:headerValue];
}
// The C envoy_headers struct can be released now because the headers have been copied.
release_envoy_headers(headers);
Expand Down