Skip to content

Commit

Permalink
[iOS] Add safe guard when receive network response data too long
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Dec 4, 2023
1 parent 3854735 commit f219904
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 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,20 @@ - (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(@"Request's received data too long."));
}];
}
[self invalidate];
return;
}

length = _data.length;
}

Expand Down

0 comments on commit f219904

Please sign in to comment.