Skip to content

Commit

Permalink
reject integer overflow in NetIsIP4()
Browse files Browse the repository at this point in the history
- better detect invalid input
  • Loading branch information
Arnaud Bouchez committed Jun 14, 2023
1 parent a961292 commit 798cf31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.1.5563'
'2.1.5564'
10 changes: 6 additions & 4 deletions src/net/mormot.net.sock.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3942,16 +3942,14 @@ function NetIsIP4(text: PUtf8Char; value: PByte): boolean;
while true do
case text^ of
#0 .. ' ':
if (b > 255) or
(b < 0) or
if (b < 0) or
(n <> 3) then
exit
else
break;
'.':
begin
if (b > 255) or
(b < 0) or
if (b < 0) or
(n = 3) then
exit;
if value <> nil then
Expand All @@ -3971,7 +3969,11 @@ function NetIsIP4(text: PUtf8Char; value: PByte): boolean;
if b < 0 then
b := o
else
begin
b := b * 10 + o;
if b > 255 then
exit; // out-of-range number
end;
inc(text);
end
else
Expand Down

0 comments on commit 798cf31

Please sign in to comment.