42
42
43
43
import static com .oracle .graal .python .nodes .ErrorMessages .INVALID_VALUE_NAN ;
44
44
import static com .oracle .graal .python .nodes .ErrorMessages .TOO_LARGE_TO_CONVERT_TO ;
45
+ import static com .oracle .graal .python .runtime .PosixSupportLibrary .FD_SETSIZE ;
46
+ import static com .oracle .graal .python .runtime .exception .PythonErrorType .ValueError ;
45
47
46
48
import java .util .List ;
47
49
@@ -177,7 +179,7 @@ private PList toList(boolean[] result, ObjAndFDList fds) {
177
179
return factory ().createList (PythonUtils .arrayCopyOf (resultObjs , resultObjsIdx ));
178
180
}
179
181
180
- private static ObjAndFDList seq2set (VirtualFrame frame , Object sequence , PythonObjectLibrary sequenceLib , PythonObjectLibrary itemLib , LookupAndCallBinaryNode callGetItemNode ,
182
+ private ObjAndFDList seq2set (VirtualFrame frame , Object sequence , PythonObjectLibrary sequenceLib , PythonObjectLibrary itemLib , LookupAndCallBinaryNode callGetItemNode ,
181
183
FastConstructListNode constructListNode , PosixResources resources ) {
182
184
PArguments .ThreadState threadState = PArguments .getThreadState (frame );
183
185
// We cannot assume any size of those two arrays, because the sequence may change as a
@@ -191,6 +193,9 @@ private static ObjAndFDList seq2set(VirtualFrame frame, Object sequence, PythonO
191
193
Object pythonObject = callGetItemNode .executeObject (frame , pSequence , i );
192
194
objects .add (pythonObject );
193
195
int fd = itemLib .asFileDescriptorWithState (pythonObject , threadState );
196
+ if (fd >= FD_SETSIZE ) {
197
+ throw raise (ValueError , ErrorMessages .FILE_DESCRIPTOR_OUT_OF_RANGE_IN_SELECT );
198
+ }
194
199
fds .add (fd );
195
200
containsSocket |= resources .isSocket (fd );
196
201
}
0 commit comments