Skip to content

Commit

Permalink
Add safe guard when receive network response data too long (#41717)
Browse files Browse the repository at this point in the history
Summary:
Fixes #41651

## Changelog:

[IOS] [FIXED] - Add safe guard when receive network response data too long

Pull Request resolved: #41717

Test Plan: None.

Reviewed By: cortinico

Differential Revision: D51981597

Pulled By: dmytrorykun

fbshipit-source-id: fabaa1490684da6725270e8ca617e3da97c56978
  • Loading branch information
zhongwuzw authored and facebook-github-bot committed Dec 13, 2023
1 parent d5b1c71 commit 3c4517f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/react-native/Libraries/Network/RCTNetworkTask.mm
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,21 @@ - (void)URLRequest:(id)requestToken didReceiveData:(NSData *)data
if (!_data) {
_data = [NSMutableData new];
}
[_data appendData:data];
@try {
[_data appendData:data];
} @catch (NSException *exception) {
_status = RCTNetworkTaskFinished;
if (_completionBlock) {
RCTURLRequestCompletionBlock completionBlock = _completionBlock;
[self dispatchCallback:^{
completionBlock(
self->_response, nil, RCTErrorWithMessage(exception.reason ?: @"Request's received data too long."));
}];
}
[self invalidate];
return;
}

length = _data.length;
}

Expand Down

0 comments on commit 3c4517f

Please sign in to comment.