mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-06 03:56:14 +02:00
rtl-extra: fix StrToHostAddr to not accept numbers outside of byte value range by silently wrapping them to a byte
git-svn-id: trunk@44845 -
This commit is contained in:
parent
8cc76b4b33
commit
0d22ee477a
@ -323,8 +323,13 @@ begin
|
|||||||
else
|
else
|
||||||
Dummy:=IP;
|
Dummy:=IP;
|
||||||
Val (Dummy,k,J);
|
Val (Dummy,k,J);
|
||||||
array4int(temp.s_addr)[i]:=k;
|
If J<>0 then
|
||||||
If J<>0 then Exit;
|
exit;
|
||||||
|
array4int(temp.s_addr)[i]:=byte(k);
|
||||||
|
{ check if after wrapping to a byte, our number is
|
||||||
|
still the same. if not, it can't be part of an IP. }
|
||||||
|
If array4int(temp.s_addr)[i]<>k then
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
strtohostaddr.s_addr:=ntohl(Temp.s_addr);
|
strtohostaddr.s_addr:=ntohl(Temp.s_addr);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user