rejetto forum

ip address over 255

Mars · 2 · 1619

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2039
    • View Profile
checkAddressSyntax has a bug , it was possible to specify values over 255

192.999.1.10  is returned as a valid address :o

Quote
function checkAddressSyntax(address:string; wildcards:boolean=TRUE):boolean;    //mod by mars
var
  a1, a2: string;
  i, dots: integer;
  wildcardsMet: boolean;
  count: integer;
begin
result:=FALSE;
if address = '' then exit;
while (address > '') and (address[1] = '\') do delete(address,1,1);
while address > '' do
  begin
  a2:=chop(';', address);
  a1:=chop('-', a2);
  if a2 > '' then
    if not checkAddressSyntax(a1, FALSE)
    or not checkAddressSyntax(a2, FALSE) then
      exit;
  wildcardsMet:=FALSE;
  dots:=0;
  count:=0;
  for i:=1 to length(a1) do
    case a1 of
      '.'     : begin count:=0; inc(dots); end;
      '0'..'9': begin count:=10*count+strtoint(a1); if count > 255 then exit; end;
      '?','*' : begin count:=0; if wildcards then wildcardsMet:=TRUE else exit; end;
      else exit;
      end;
  if (dots > 3) or not wildcardsMet and (dots <> 3) then exit;
  end;
result:=TRUE;
end; // checkAddressSyntax

Now , it is not possible ;)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile