X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/44dc132f5dc6ced75e4225826b4eb0dda63392ab..1c8b91ca0f6891a397357c7cf7d77af18c15937d:/fd_utils.pas

diff --git a/fd_utils.pas b/fd_utils.pas
old mode 100755
new mode 100644
index 290eb05..86b6d3a
--- a/fd_utils.pas
+++ b/fd_utils.pas
@@ -48,7 +48,7 @@ uses sysutils;
 Procedure FD_Clr(fd:longint;var fds:fdSet);{$ifdef useinline}inline;{$endif}
 { Remove fd from the set of filedescriptors}
 begin
-  if (fd < 0) then raise exception.create('FD_Clr fd out of range: '+inttostr(fd));
+  if (fd < 0) or ((fd shr fdwordshift) > high(fdset)) then raise exception.create('FD_Clr fd out of range: '+inttostr(fd));
   fds[fd shr fdwordshift]:=fds[fd shr fdwordshift] and (not (1 shl (fd and fdwordmaxbit)));
 end;
 
@@ -61,14 +61,14 @@ end;
 Procedure FD_Set(fd:longint;var fds:fdSet);{$ifdef useinline}inline;{$endif}
 { Add fd to the set of filedescriptors }
 begin
-  if (fd < 0) then raise exception.create('FD_set fd out of range: '+inttostr(fd));
+  if (fd < 0) or ((fd shr fdwordshift) > high(fdset)) then raise exception.create('FD_set fd out of range: '+inttostr(fd));
   fds[fd shr fdwordshift]:=fds[fd shr fdwordshift] or (1 shl (fd and fdwordmaxbit));
 end;
 
 Function FD_IsSet(fd:longint;var fds:fdSet):boolean;{$ifdef useinline}inline;{$endif}
 { Test if fd is part of the set of filedescriptors }
 begin
-  if (fd < 0) then begin
+  if (fd < 0) or ((fd shr fdwordshift) > high(fdset)) then begin
     result := false;
     exit;
   end;