Skip to content

Commit 938d3be

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
Revert "Add various missing argument checks to dart:io natives."
This reverts commit ba72890. Reason for revert: Crash in bytecode modes Original change's description: > Add various missing argument checks to dart:io natives. > > Change type checks in embedding API functions to return UnhandledExceptionErrors instead of APIErrors so they are catchable by Dart. > > Fixes invocation_fuzz_test. > > Bug: #15274 > Bug: #23869 > Change-Id: Ia6103e7ffceda897e475c1a3ba534c2f4b910475 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110020 > Commit-Queue: Ryan Macnak <[email protected]> > Reviewed-by: Siva Annamalai <[email protected]> [email protected],[email protected],[email protected] Change-Id: Ib52ec03caf4b177cd91bb1d366df51588bf23177 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: #15274, #23869 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110580 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 8fb4240 commit 938d3be

File tree

16 files changed

+119
-156
lines changed

16 files changed

+119
-156
lines changed

runtime/bin/file.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ static File* GetFile(Dart_NativeArguments args) {
4242
Dart_Handle result = Dart_GetNativeInstanceField(
4343
dart_this, kFileNativeFieldIndex, reinterpret_cast<intptr_t*>(&file));
4444
ASSERT(!Dart_IsError(result));
45-
if (file == NULL) {
46-
Dart_PropagateError(Dart_NewUnhandledExceptionError(
47-
DartUtils::NewInternalError("No native peer")));
48-
}
4945
return file;
5046
}
5147

runtime/bin/namespace.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Dart_Handle Namespace::GetNativeNamespaceArgument(Dart_NativeArguments args,
119119
Namespace** namespc) {
120120
Dart_Handle namespc_obj = Dart_GetNativeArgument(args, index);
121121
if (Dart_IsError(namespc_obj)) {
122-
return namespc_obj;
122+
Dart_PropagateError(namespc_obj);
123123
}
124124
DEBUG_ASSERT(IsNamespace(namespc_obj));
125125

@@ -129,10 +129,6 @@ Dart_Handle Namespace::GetNativeNamespaceArgument(Dart_NativeArguments args,
129129
if (Dart_IsError(result)) {
130130
return result;
131131
}
132-
if (*namespc == NULL) {
133-
return Dart_NewUnhandledExceptionError(
134-
DartUtils::NewInternalError("No native peer"));
135-
}
136132
return Dart_Null();
137133
}
138134

runtime/bin/secure_socket_filter.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@ const intptr_t SSLFilter::kApproximateSize =
3838
sizeof(SSLFilter) + (2 * SSLFilter::kInternalBIOSize);
3939

4040
static SSLFilter* GetFilter(Dart_NativeArguments args) {
41-
SSLFilter* filter = NULL;
41+
SSLFilter* filter;
4242
Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0));
4343
ASSERT(Dart_IsInstance(dart_this));
4444
ThrowIfError(Dart_GetNativeInstanceField(
4545
dart_this, SSLFilter::kSSLFilterNativeFieldIndex,
4646
reinterpret_cast<intptr_t*>(&filter)));
47-
if (filter == NULL) {
48-
Dart_PropagateError(Dart_NewUnhandledExceptionError(
49-
DartUtils::NewInternalError("No native peer")));
50-
}
5147
return filter;
5248
}
5349

runtime/bin/secure_socket_patch.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class SecureSocket {
1414
@patch
1515
class _SecureFilter {
1616
@patch
17-
factory _SecureFilter._() => new _SecureFilterImpl._();
17+
factory _SecureFilter() => new _SecureFilterImpl();
1818
}
1919

2020
@patch
2121
@pragma("vm:entry-point")
2222
class X509Certificate {
2323
@patch
2424
@pragma("vm:entry-point")
25-
factory X509Certificate._() => new _X509CertificateImpl._();
25+
factory X509Certificate._() => new _X509CertificateImpl();
2626
}
2727

2828
class _SecureSocket extends _Socket implements SecureSocket {
@@ -75,7 +75,7 @@ class _SecureFilterImpl extends NativeFieldWrapperClass1
7575
@pragma("vm:entry-point")
7676
static final int ENCRYPTED_SIZE = 10 * 1024;
7777

78-
_SecureFilterImpl._() {
78+
_SecureFilterImpl() {
7979
buffers = new List<_ExternalBuffer>(_RawSecureSocket.bufferCount);
8080
for (int i = 0; i < _RawSecureSocket.bufferCount; ++i) {
8181
buffers[i] = new _ExternalBuffer(
@@ -206,7 +206,7 @@ class _X509CertificateImpl extends NativeFieldWrapperClass1
206206
implements X509Certificate {
207207
// The native field must be set manually on a new object, in native code.
208208
// This is done by WrappedX509 in secure_socket.cc.
209-
_X509CertificateImpl._();
209+
_X509CertificateImpl();
210210

211211
Uint8List _cachedDer;
212212
Uint8List get _der native "X509_Der";

runtime/bin/security_context.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ SSLCertContext* SSLCertContext::GetSecurityContext(Dart_NativeArguments args) {
8686
ThrowIfError(Dart_GetNativeInstanceField(
8787
dart_this, SSLCertContext::kSecurityContextNativeFieldIndex,
8888
reinterpret_cast<intptr_t*>(&context)));
89-
if (context == NULL) {
90-
Dart_PropagateError(Dart_NewUnhandledExceptionError(
91-
DartUtils::NewInternalError("No native peer")));
92-
}
9389
return context;
9490
}
9591

@@ -648,10 +644,6 @@ static X509* GetX509Certificate(Dart_NativeArguments args) {
648644
ThrowIfError(Dart_GetNativeInstanceField(
649645
dart_this, SSLCertContext::kX509NativeFieldIndex,
650646
reinterpret_cast<intptr_t*>(&certificate)));
651-
if (certificate == NULL) {
652-
Dart_PropagateError(Dart_NewUnhandledExceptionError(
653-
DartUtils::NewInternalError("No native peer")));
654-
}
655647
return certificate;
656648
}
657649

runtime/bin/socket.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,10 +1106,6 @@ Socket* Socket::GetSocketIdNativeField(Dart_Handle socket_obj) {
11061106
Dart_PropagateError(err);
11071107
}
11081108
Socket* socket = reinterpret_cast<Socket*>(id);
1109-
if (socket == NULL) {
1110-
Dart_PropagateError(Dart_NewUnhandledExceptionError(
1111-
DartUtils::NewInternalError("No native peer")));
1112-
}
11131109
return socket;
11141110
}
11151111

runtime/bin/sync_socket.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,6 @@ Dart_Handle SynchronousSocket::GetSocketIdNativeField(
351351
return result;
352352
}
353353
*socket = reinterpret_cast<SynchronousSocket*>(id);
354-
if (*socket == NULL) {
355-
Dart_PropagateError(Dart_NewUnhandledExceptionError(
356-
DartUtils::NewInternalError("No native peer")));
357-
}
358354
return result;
359355
}
360356

runtime/bin/sync_socket_patch.dart

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
9191
var address = it.current;
9292
var socket = new _NativeSynchronousSocket();
9393
socket.localAddress = address;
94-
var result = socket._nativeCreateConnectSync(address._in_addr, port);
94+
var result = socket.nativeCreateConnectSync(address._in_addr, port);
9595
if (result is OSError) {
9696
// Keep first error, if present.
9797
if (error == null) {
@@ -117,7 +117,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
117117
}
118118

119119
InternetAddress get address => localAddress;
120-
int get available => _nativeAvailable();
120+
int get available => nativeAvailable();
121121

122122
int get port {
123123
if (localPort != 0) {
@@ -126,7 +126,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
126126
if (isClosed) {
127127
throw const SocketException.closed();
128128
}
129-
var result = _nativeGetPort();
129+
var result = nativeGetPort();
130130
if (result is OSError) {
131131
throw result;
132132
}
@@ -137,7 +137,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
137137
if (isClosed) {
138138
throw const SocketException.closed();
139139
}
140-
var result = _nativeGetRemotePeer();
140+
var result = nativeGetRemotePeer();
141141
if (result is OSError) {
142142
throw result;
143143
}
@@ -149,7 +149,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
149149
if (isClosed) {
150150
throw const SocketException.closed();
151151
}
152-
var result = _nativeGetRemotePeer();
152+
var result = nativeGetRemotePeer();
153153
if (result is OSError) {
154154
throw result;
155155
}
@@ -158,7 +158,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
158158

159159
void closeSync() {
160160
if (!isClosed) {
161-
_nativeCloseSync();
161+
nativeCloseSync();
162162
_SocketResourceInfo.SocketClosed(resourceInfo);
163163
isClosed = true;
164164
}
@@ -209,7 +209,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
209209
if (end == start) {
210210
return 0;
211211
}
212-
var result = _nativeReadInto(buffer, start, (end - start));
212+
var result = nativeReadInto(buffer, start, (end - start));
213213
if (result is OSError) {
214214
throw new SocketException("readIntoSync failed", osError: result);
215215
}
@@ -229,7 +229,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
229229
if (len == 0) {
230230
return null;
231231
}
232-
var result = _nativeRead(len);
232+
var result = nativeRead(len);
233233
if (result is OSError) {
234234
throw result;
235235
}
@@ -275,7 +275,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
275275
if (isClosedWrite) {
276276
closeSync();
277277
} else {
278-
_nativeShutdownRead();
278+
nativeShutdownRead();
279279
}
280280
isClosedRead = true;
281281
}
@@ -287,7 +287,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
287287
if (isClosedRead) {
288288
closeSync();
289289
} else {
290-
_nativeShutdownWrite();
290+
nativeShutdownWrite();
291291
}
292292
isClosedWrite = true;
293293
}
@@ -313,7 +313,7 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
313313

314314
_BufferAndStart bufferAndStart =
315315
_ensureFastAndSerializableByteData(buffer, start, end);
316-
var result = _nativeWrite(bufferAndStart.buffer, bufferAndStart.start,
316+
var result = nativeWrite(bufferAndStart.buffer, bufferAndStart.start,
317317
end - (start - bufferAndStart.start));
318318
if (result is OSError) {
319319
throw new SocketException("writeFromSync failed", osError: result);
@@ -333,17 +333,17 @@ class _NativeSynchronousSocket extends _NativeSynchronousSocketNativeWrapper {
333333
// Native method declarations.
334334
static _nativeLookupRequest(host, int type)
335335
native "SynchronousSocket_LookupRequest";
336-
_nativeCreateConnectSync(host, int port)
336+
nativeCreateConnectSync(host, int port)
337337
native "SynchronousSocket_CreateConnectSync";
338-
_nativeAvailable() native "SynchronousSocket_Available";
339-
_nativeCloseSync() native "SynchronousSocket_CloseSync";
340-
int _nativeGetPort() native "SynchronousSocket_GetPort";
341-
List _nativeGetRemotePeer() native "SynchronousSocket_GetRemotePeer";
342-
_nativeRead(int len) native "SynchronousSocket_Read";
343-
_nativeReadInto(List<int> buffer, int offset, int bytes)
338+
nativeAvailable() native "SynchronousSocket_Available";
339+
nativeCloseSync() native "SynchronousSocket_CloseSync";
340+
int nativeGetPort() native "SynchronousSocket_GetPort";
341+
List nativeGetRemotePeer() native "SynchronousSocket_GetRemotePeer";
342+
nativeRead(int len) native "SynchronousSocket_Read";
343+
nativeReadInto(List<int> buffer, int offset, int bytes)
344344
native "SynchronousSocket_ReadList";
345-
_nativeShutdownRead() native "SynchronousSocket_ShutdownRead";
346-
_nativeShutdownWrite() native "SynchronousSocket_ShutdownWrite";
347-
_nativeWrite(List<int> buffer, int offset, int bytes)
345+
nativeShutdownRead() native "SynchronousSocket_ShutdownRead";
346+
nativeShutdownWrite() native "SynchronousSocket_ShutdownWrite";
347+
nativeWrite(List<int> buffer, int offset, int bytes)
348348
native "SynchronousSocket_WriteList";
349349
}

0 commit comments

Comments
 (0)