Skip to content
Permalink
Browse files

let IPToCardinal() set the value to 0 on parse error

  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Jun 20, 2019
1 parent ea68547 commit 21c90dc1f22586453c8d75a9007cd1cc6e6cbc66
Showing with 16 additions and 13 deletions.
  1. +5 −6 SQLite3/mORMot.pas
  2. +8 −5 SynCommons.pas
  3. +2 −1 SynCrypto.pas
  4. +1 −1 SynopseCommit.inc
@@ -3589,6 +3589,10 @@ TSQLPropInfoRTTIInt64 = class(TSQLPropInfoRTTI)
procedure GetJSONValues(Instance: TObject; W: TJSONSerializer); override;
end;

/// information about a PtrInt published property, according to the native CPU
// - not a real stand-alone class, but a convenient wrapper type
TSQLPropInfoRTTIPtrInt = {$ifdef CPU64}TSQLPropInfoRTTIInt64{$else}TSQLPropInfoRTTIInt32{$endif};

/// information about a TTimeLog published property
// - stored as an Int64, but with a specific class
TSQLPropInfoRTTITimeLog = class(TSQLPropInfoRTTIInt64);
@@ -5208,18 +5212,13 @@ EInterfaceResolverException = class(ESynException);
/// exception dedicated to interface based service implementation
EServiceException = class(EORMException);


/// information about a TSQLRecord class property
// - sftID for TSQLRecord properties, which are pointer(RecordID), not
// any true class instance
// - sftMany for TSQLRecordMany properties, for which no data is
// stored in the table itself, but in a pivot table
// - sftObject for e.g. TStrings TRawUTF8List TCollection instances
{$ifdef CPU64}
TSQLPropInfoRTTIInstance = class(TSQLPropInfoRTTIInt64)
{$else}
TSQLPropInfoRTTIInstance = class(TSQLPropInfoRTTIInt32)
{$endif}
TSQLPropInfoRTTIInstance = class(TSQLPropInfoRTTIPtrInt)
protected
fObjectClass: TClass;
public

function IPToCardinal(P: PUTF8Char; out aValue: cardinal): boolean;
var i,c: cardinal;
b: array[0..3] of byte absolute aValue;
b: array[0..3] of byte;
begin
aValue := 0;
result := false;
if (P=nil) or (IdemPChar(P,'127.0.0.1') and (P[9]=#0)) then
exit;
for i := 0 to 3 do begin
c := GetNextItemCardinal(P,'.');
if (c>255) or ((i<3) and (P=nil)) then
if (c>255) or ((P=nil) and (i<3)) then
exit;
b[i] := c;
end;
result := aValue<>$0100007f;
if PCardinal(@b)^<>$0100007f then begin
aValue := PCardinal(@b)^;
result := true;
end;
end;

function IPToCardinal(const aIP: RawUTF8; out aValue: cardinal): boolean;

function IPToCardinal(const aIP: RawUTF8): cardinal;
begin
if not IPToCardinal(pointer(aIP),result) then
result := 0;
IPToCardinal(pointer(aIP),result);
end;

const
@@ -410,6 +410,7 @@ {$ifdef UNICODE}THash128History = record{$else}THash128History = object{$endif
/// how many THash128 values are currently stored
Count: integer;
/// initialize the storage for a given history depth
// - if Count reaches Depth, then older items will be removed
procedure Init(size, maxsize: integer);
/// O(n) fast search of a hash value in the stored entries
// - returns true if the hash was found, or false if it did not appear
@@ -14086,7 +14087,7 @@ function THash128History.Add(const hash: THash128): boolean;
if Index>=length(Previous) then
if Index=Depth then
Index := 0 else begin
n := Index+Index shr 3;
n := NextGrow(Index);
if n>=Depth then
n := Depth;
SetLength(Previous,n);
@@ -1 +1 @@
'1.18.5249'
'1.18.5250'

0 comments on commit 21c90dc

Please sign in to comment.
You can’t perform that action at this time.