40
40
*/
41
41
package com .oracle .graal .python .builtins .objects .ssl ;
42
42
43
+ import static com .oracle .graal .python .builtins .PythonBuiltinClassType .MemoryError ;
43
44
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .OSError ;
44
45
45
46
import java .io .IOException ;
57
58
import com .oracle .graal .python .builtins .objects .socket .SocketUtils .TimeoutHelper ;
58
59
import com .oracle .graal .python .nodes .ErrorMessages ;
59
60
import com .oracle .graal .python .nodes .PNodeWithRaise ;
61
+ import com .oracle .graal .python .nodes .PRaiseNode ;
60
62
import com .oracle .graal .python .runtime .exception .PException ;
63
+ import com .oracle .graal .python .util .OverflowException ;
61
64
import com .oracle .truffle .api .CompilerDirectives ;
62
65
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
63
66
@@ -308,13 +311,14 @@ private static void loop(PNodeWithRaise node, PSSLSocket socket, ByteBuffer appI
308
311
} catch (IOException e ) {
309
312
// TODO better error handling, distinguish SSL errors and socket errors
310
313
throw PRaiseSSLErrorNode .raiseUncached (node , SSLErrorCode .ERROR_SYSCALL , e .toString ());
314
+ } catch (OverflowException | OutOfMemoryError e ) {
315
+ throw PRaiseNode .raiseUncached (node , MemoryError );
311
316
}
312
317
// TODO handle other socket errors (NotYetConnected)
313
- // TODO handle OOM
314
318
}
315
319
316
320
private static SSLEngineResult doUnwrap (SSLEngine engine , MemoryBIO networkInboundBIO , ByteBuffer targetBuffer , MemoryBIO applicationInboundBIO , boolean writeDirectlyToTarget )
317
- throws SSLException {
321
+ throws SSLException , OverflowException {
318
322
ByteBuffer readBuffer = networkInboundBIO .getBufferForReading ();
319
323
try {
320
324
if (writeDirectlyToTarget ) {
@@ -334,7 +338,7 @@ private static SSLEngineResult doUnwrap(SSLEngine engine, MemoryBIO networkInbou
334
338
}
335
339
}
336
340
337
- private static SSLEngineResult doWrap (SSLEngine engine , ByteBuffer appInput , MemoryBIO networkOutboundBIO , int netBufferSize ) throws SSLException {
341
+ private static SSLEngineResult doWrap (SSLEngine engine , ByteBuffer appInput , MemoryBIO networkOutboundBIO , int netBufferSize ) throws SSLException , OverflowException {
338
342
networkOutboundBIO .ensureWriteCapacity (netBufferSize );
339
343
ByteBuffer writeBuffer = networkOutboundBIO .getBufferForWriting ();
340
344
try {
@@ -351,7 +355,7 @@ private static PException handleSSLException(PNodeWithRaise node, SSLException e
351
355
throw PRaiseSSLErrorNode .raiseUncached (node , SSLErrorCode .ERROR_SSL , e .toString ());
352
356
}
353
357
354
- private static int obtainMoreInput (PNodeWithRaise node , SSLEngine engine , MemoryBIO networkInboundBIO , PSocket socket , TimeoutHelper timeoutHelper ) throws IOException {
358
+ private static int obtainMoreInput (PNodeWithRaise node , SSLEngine engine , MemoryBIO networkInboundBIO , PSocket socket , TimeoutHelper timeoutHelper ) throws IOException , OverflowException {
355
359
if (socket != null ) {
356
360
if (socket .getSocket () == null ) {
357
361
// TODO use raiseOsError with ENOTCONN
0 commit comments