diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-06 09:28:33 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-09-06 09:28:33 +0000 |
commit | 7068ba79ee3dafb64422373bd4ba154c9583b211 (patch) | |
tree | edd093c1640864e8638de2608c1a9c9f83be08d0 /gcc/ada/g-socket.adb | |
parent | 8fc2605c52b4a6e471f849ba6d4fdf81ae0897f1 (diff) | |
download | gcc-7068ba79ee3dafb64422373bd4ba154c9583b211.tar.gz |
2011-09-06 Robert Dewar <dewar@adacore.com>
* sem_ch8.ads: Minor reformatting
2011-09-06 Thomas Quinot <quinot@adacore.com>
* s-oscons-tmplt.c, g-socket.adb (GNAT.Sockets.Clear,Set,Is_Set):
Guard against socket values that are not in [0;FD_SETSIZE[
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178576 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/g-socket.adb')
-rw-r--r-- | gcc/ada/g-socket.adb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index c562a84944c..0f025800163 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2010, AdaCore -- +-- Copyright (C) 2001-2011, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -195,6 +195,11 @@ package body GNAT.Sockets is procedure Narrow (Item : in out Socket_Set_Type); -- Update Last as it may be greater than the real last socket + procedure Check_For_Fd_Set (Fd : Socket_Type); + pragma Inline (Check_For_Fd_Set); + -- Raise Constraint_Error if Fd is less than 0 or greater than or equal to + -- FD_SETSIZE. + -- Types needed for Datagram_Socket_Stream_Type type Datagram_Socket_Stream_Type is new Root_Stream_Type with record @@ -568,6 +573,18 @@ package body GNAT.Sockets is Narrow (E_Socket_Set); end Check_Selector; + ---------------------- + -- Check_For_Fd_Set -- + ---------------------- + + procedure Check_For_Fd_Set (Fd : Socket_Type) is + begin + if Fd < 0 or else Fd >= SOSC.FD_SETSIZE then + raise Constraint_Error with "invalid value for socket set: " + & Image (Fd); + end if; + end Check_For_Fd_Set; + ----------- -- Clear -- ----------- @@ -578,6 +595,7 @@ package body GNAT.Sockets is is Last : aliased C.int := C.int (Item.Last); begin + Check_For_Fd_Set (Socket); if Item.Last /= No_Socket then Remove_Socket_From_Set (Item.Set'Access, C.int (Socket)); Last_Socket_In_Set (Item.Set'Access, Last'Unchecked_Access); @@ -1454,6 +1472,7 @@ package body GNAT.Sockets is Socket : Socket_Type) return Boolean is begin + Check_For_Fd_Set (Socket); return Item.Last /= No_Socket and then Socket <= Item.Last and then Is_Socket_In_Set (Item.Set'Access, C.int (Socket)) /= 0; @@ -2100,6 +2119,7 @@ package body GNAT.Sockets is procedure Set (Item : in out Socket_Set_Type; Socket : Socket_Type) is begin + Check_For_Fd_Set (Socket); if Item.Last = No_Socket then -- Uninitialized socket set, make sure it is properly zeroed out |