react-native/Libraries/Network
Chris Lewis 1c04ceeb4b Check against integer overflow in RCTNetworking decodeTextData
Summary:
It's currently possible to crash React Native on iOS when using XMLHTTPRequest with onreadystatechange by having the server send a bunch of bad unicode (we found the problem when a bad deploy caused this to happen).

This is due to an integer overflow when handling carryover data in decodeTextData.

Create Express server with mock endpoint:

```js
var express = require('express');
var app = express();

app.get('/', function(req, res) {
  res.writeHead(200, {'content-type': 'text/plain; charset=utf-8'});
  res.flushHeaders();
  res.write(new Buffer(Array(4097).join(0x48).concat(0xC2)));
  res.write(new Buffer([0xA9]));
  res.end();
});

app.listen(3000);
```

Create React Native application which tries to hit the endpoint:

```js
export default class App extends Component<{}> {
  componentDidMount() {
    const xhr = new XMLHttpRequest()
    xhr.open('get', 'http://localhost:3000', true);
    xhr.onreadystatechange = function () {
      if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
        console.warn(xhr.responseText);
      }
    };
    xhr.send();
  }

  render() {
    return null;
  }
}
```

Observe that the application crashes when running master and doesn't when including the changes from this pull request.

[IOS] [BUGFIX] [RCTNetworking] - |Check against integer overflow when parsing response|
Closes https://github.com/facebook/react-native/pull/16286

Differential Revision: D6060975

Pulled By: hramos

fbshipit-source-id: 650e401a3bc033725078ea064f8fbca5441f9db5
2017-11-07 08:08:41 -08:00
..
RCTNetwork.xcodeproj Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
__tests__ Adding @email tags to most of the tests 2017-11-02 06:25:03 -07:00
FormData.js Network/FormData typeof object allowing null 2017-02-10 13:30:48 -08:00
NetInfo.js Update the `NetInfo.isConnected` example code so that it uses the new `connectionChange` event 2017-10-13 18:02:06 -07:00
RCTDataRequestHandler.h Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTDataRequestHandler.m Fix retain cyles in RCTNetworkTask when used with RCTFileRequestHandler and RCTDataRequestHandler 2015-11-04 07:16:26 -08:00
RCTFileRequestHandler.h Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTFileRequestHandler.m Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTHTTPRequestHandler.h Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTHTTPRequestHandler.mm Added Cookie Header to XML and Websocket request 2017-05-24 09:47:37 -07:00
RCTNetInfo.h Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTNetInfo.m DEPRECATION: Make NetInfo API cross platform and expose whether connection is 2g/3g/4g 2017-07-24 15:50:53 -07:00
RCTNetworkTask.h Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTNetworkTask.m Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTNetworking.android.js Fix RCTNetworking error message 2017-07-11 09:10:20 -07:00
RCTNetworking.h Move all header imports to "<React/..>" 2016-11-23 07:58:39 -08:00
RCTNetworking.ios.js Fix RCTNetworking error message 2017-07-11 09:10:20 -07:00
RCTNetworking.mm Check against integer overflow in RCTNetworking decodeTextData 2017-11-07 08:08:41 -08:00
XHRInterceptor.js Reorganize core JS files 2016-10-11 10:14:28 -07:00
XMLHttpRequest.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
convertRequestBody.js XHR: support typed arrays for request payloads 2017-01-20 18:43:27 -08:00
fetch.js Migrate tests away from "jsdom" environment 2017-09-11 09:49:11 -07:00