diff --git a/SRC/SrvMain.pas b/SRC/SrvMain.pas index 974f101..40ffbbd 100755 --- a/SRC/SrvMain.pas +++ b/SRC/SrvMain.pas @@ -321,6 +321,7 @@ function StrToFileTime(AStr: AnsiString): DWORD; Result := INVALID_FILE_TIME; Clear(d, SizeOf(d)); s := AStr; + z := ''; GetWrd(s, z, ' '); GetWrdD(s, z); v := Vl(z); @@ -698,6 +699,7 @@ procedure TPipeWriteStdThread.Execute; slen: Integer; begin slen := Length(s); + j := 0; if slen > 0 then WriteFile(HPipe, s[1], slen, j, nil); end; @@ -724,6 +726,7 @@ function DoCollect(Collector: TCollector; EntityHeader: TEntityHeader; end else begin + z := ''; GetWrdStrictUC(s, z); Delete(z, Length(z), 1); if not EntityHeader.Filter(z, s) then @@ -742,6 +745,8 @@ procedure TPipeReadErrThread.Execute; j: DWORD; begin repeat + j := 0; + FillChar(ss, SizeOf(ss), 0); if (not ReadFile(HPipe, ss[1], 250, j, nil)) or (j = 0) then Break; ss[0] := AnsiChar(j); @@ -754,6 +759,7 @@ procedure TPipeReadStdThread.Execute; j: DWORD; begin repeat + j := 0; if (not ReadFile(HPipe, Buffer^, CHTTPServerThreadBufSize, j, nil)) or (j = 0) then Break; @@ -786,6 +792,9 @@ function ExecuteScript(const AExecutable, APath, AScript, AQueryParam, AEnvStr, var d, n, e: AnsiString; begin + d := ''; + n := ''; + e := ''; FSPlit(AExecutable, d, n, e); Result := n + e + ' is a GUI application'; end; @@ -925,6 +934,7 @@ function ExecuteScript(const AExecutable, APath, AScript, AQueryParam, AEnvStr, while not PipeReadStdThread.Error do begin + Actually := 0; if (not ReadFile(so_r, Buffer, CHTTPServerThreadBufSize, Actually, nil)) or (Actually = 0) then Break; @@ -965,6 +975,7 @@ procedure AddAgentLog(const AAgent: AnsiString); s := AAgent + #13#10; EnterCriticalSection(CSAgentLog); slen := Length(s); + b := 0; WriteFile(HAgentLog, s[1], slen, b, nil); LeaveCriticalSection(CSAgentLog); end; @@ -980,6 +991,7 @@ procedure AddRefererLog(const ARefererSrc, ARefererDst: AnsiString); s := ARefererSrc + ' -> ' + ARefererDst + #13#10; EnterCriticalSection(CSRefererLog); slen := Length(s); + b := 0; WriteFile(HRefererLog, s[1], slen, b, nil); LeaveCriticalSection(CSRefererLog); end; @@ -990,6 +1002,8 @@ function CurTime: AnsiString; b: Integer; s: AnsiString; begin + s := ''; + FillChar(lt, SizeOf(lt), 0); GetLocalTime(lt); b := TimeZoneBias; if b < 0 then @@ -1037,6 +1051,7 @@ procedure AddAccessLog(const ARemoteHost, ARequestLine, AHTTPVersion, #13#10; EnterCriticalSection(CSAccessLog); slen := Length(z); + b := 0; WriteFile(HAccessLog, z[1], slen, b, nil); LeaveCriticalSection(CSAccessLog); end; @@ -1050,6 +1065,7 @@ procedure AddErrorLog(const AErr: AnsiString); s := CurTime + ' ' + AErr + #13#10; EnterCriticalSection(CSErrorLog); slen := Length(s); + b := 0; WriteFile(HErrorLog, s[1], slen, b, nil); LeaveCriticalSection(CSErrorLog); end; @@ -1124,6 +1140,7 @@ function OpenRequestedFile(const AFName: AnsiString; thr: THTTPServerThread; z := LowerCase(CopyLeft(ExtractFileExt(AFName), 2)); if z <> '' then begin + i := -1; if not ContentTypes.Search(@z, i) then z := '' else @@ -1251,6 +1268,7 @@ function FindExecutableCached(const LocalFName, sPath: AnsiString; Exit; end; ExecutableCache.Enter; + i := -1; if ExecutableCache.Search(@LocalFName, i) then begin p := ExecutableCache[i]; @@ -1314,6 +1332,7 @@ function FindRootFileEx(const AURI: AnsiString; var IsCGI: Boolean): AnsiString; s := GetEnvVariable('PATHEXT'); while s <> '' do begin + z := ''; GetWrd(s, z, ';'); if Length(z) < 2 then Continue; @@ -1337,6 +1356,7 @@ function FindRootFile(const AURI: AnsiString; var IsCGI: Boolean): AnsiString; p: Pointer; begin RootCacheColl.Enter; + i := -1; Found := RootCacheColl.Search(@AURI, i); if Found then begin @@ -1513,6 +1533,7 @@ function WebServerHttpResponse(thr: THTTPServerThread; d: THTTPData) PathInfo := CopyLeft(LocalFName, Length(CgiFile) + 2); ts := PathInfo; repeat + z := ''; GetWrd(ts, z, '\'); CgiFile := CgiFile + '\' + z; fa := GetFileAttributesA(@(CgiFile[1])); @@ -1664,6 +1685,7 @@ function WebServerHttpResponse(thr: THTTPServerThread; d: THTTPData) if CheckedURI[Length(CheckedURI)] = '\' then begin + IsCGI := False; LocalFName := FindRootFile(CheckedURI, IsCGI); if IsCGI then begin @@ -1788,6 +1810,7 @@ procedure THTTPServerThread.Execute; // Parse HTTP version s := HTTPVersion; + z := ''; GetWrd(s, z, '/'); if z <> 'HTTP' then Break; @@ -2319,9 +2342,9 @@ procedure THTTPServerThread.Execute; { Allocate an object instance } - function CalcJmpOffset(Src, Dest: Pointer): Longint; + function CalcJmpOffset(Src, Dest: Pointer): NativeInt; begin - Result := Longint(Dest) - (Longint(Src) + 5); + Result := NativeInt(Dest) - (NativeInt(Src) + 5); end; function MakeObjectInstance(Method: TWndMethod): Pointer; @@ -2345,8 +2368,8 @@ procedure THTTPServerThread.Execute; Instance^.Offset := CalcJmpOffset(Instance, @Block^.Code); Instance^.Next := InstFreeList; InstFreeList := Instance; - Inc(Longint(Instance), SizeOf(TObjectInstance)); - until Longint(Instance) - Longint(Block) >= SizeOf(TInstanceBlock); + Inc(NativeInt(Instance), SizeOf(TObjectInstance)); + until NativeInt(Instance) - NativeInt(Block) >= SizeOf(TInstanceBlock); InstBlockList := Block; end; Result := InstFreeList; @@ -2378,6 +2401,7 @@ procedure THTTPServerThread.Execute; begin UtilWindowClass.hInstance := hInstance; UtilWindowClass.lpfnWndProc := @DefWindowProc; + FillChar(TempClass, SizeOf(TempClass), 0); ClassRegistered := GetClassInfo(hInstance, UtilWindowClass.lpszClassName, TempClass); if not ClassRegistered or ({$IFDEF FPC_DELPHI}@{$ENDIF}TempClass.lpfnWndProc @@ -2390,7 +2414,7 @@ procedure THTTPServerThread.Execute; Result := CreateWindowEx(WS_EX_TOOLWINDOW, UtilWindowClass.lpszClassName, '', WS_POPUP { !0 } , 0, 0, 0, 0, 0, 0, hInstance, nil); if Assigned(Method) then - SetWindowLong(Result, GWL_WNDPROC, Longint(MakeObjectInstance(Method))); + SetWindowLong(Result, GWL_WNDPROC, LONG(MakeObjectInstance(Method))); end; procedure DeallocateHWnd(Wnd: HWND); @@ -2446,6 +2470,7 @@ TMainThread = class(TThread) s: AnsiString; begin Leave := False; + FillChar(WData, SizeOf(WData), 0); err := WSAStartup(MakeWord(1, 1), WData); if err <> 0 then begin @@ -2531,6 +2556,7 @@ TMainThread = class(TThread) WP := TWndProc.Create; WP.Handle := AllocateHWnd({$IFDEF FPC_OBJFPC}@{$ENDIF}WP.WndProc); repeat + FillChar(M, SizeOf(M), 0); GetMessage(M, 0, 0, 0); if M.Message = WM_QUIT then begin diff --git a/SRC/xBase.pas b/SRC/xBase.pas index a2b5a70..f0dda0d 100755 --- a/SRC/xBase.pas +++ b/SRC/xBase.pas @@ -652,6 +652,7 @@ function uFindFirst(const FName: AnsiString; var FindData: TuFindData): THandle; end else begin + FillChar(wf, SizeOf(wf), 0); Result := FindFirstFileA(@(FName[1]), wf); if Result <> INVALID_HANDLE_VALUE then CvtFD(wf, FindData); @@ -662,6 +663,7 @@ function uFindNext(Handle: THandle; var FindData: TuFindData): Boolean; var wf: TWin32FindDataA; begin + FillChar(wf, SizeOf(wf), 0); Result := FindNextFileA(Handle, wf); if Result then CvtFD(wf, FindData); @@ -707,6 +709,7 @@ function BothKVC(const S: AnsiString): Boolean; function AddRightSpaces(const S: AnsiString; NumSpaces: Integer): AnsiString; begin + Result := ''; SetLength(Result, NumSpaces); FillChar(Result[1], NumSpaces, ' '); Move(S[1], Result[1], MinI(NumSpaces, Length(S))); @@ -714,6 +717,7 @@ function AddRightSpaces(const S: AnsiString; NumSpaces: Integer): AnsiString; function Hex2(a: Byte): AnsiString; begin + Result := ''; SetLength(Result, 2); Result[1] := rrLoHexChar[a shr 4]; Result[2] := rrLoHexChar[a and $F]; @@ -723,6 +727,7 @@ function Hex4(a: Word): AnsiString; var I: Integer; begin + Result := ''; SetLength(Result, 4); for I := 0 to 3 do begin @@ -735,6 +740,7 @@ function Hex8(a: DWORD): AnsiString; var I: DWORD; begin + Result := ''; SetLength(Result, 8); for I := 0 to 7 do begin @@ -1495,6 +1501,7 @@ function _GetFileSize(const FName: AnsiString): DWORD; function WindowsDirectory: AnsiString; begin + Result := ''; SetLength(Result, MAX_PATH); GetWindowsDirectoryA(@(Result[1]), MAX_PATH); SetLength(Result, NulSearch(Result[1])); @@ -1570,6 +1577,7 @@ function ReadRegString(Key: DWORD; const AStrName: AnsiString): AnsiString; PDataBuf: PAnsiChar; begin L := 250; + z := ''; SetLength(z, L + 1); PDataBuf := @(z[1]); T := REG_SZ; @@ -1940,6 +1948,7 @@ function TSortedColl.IndexOf(Item: Pointer): Integer; I: Integer; begin IndexOf := -1; + I := -1; if Search(KeyOf(Item), I) then begin if Duplicates then @@ -1954,6 +1963,7 @@ procedure TSortedColl.Insert(Item: Pointer); var I: Integer; begin + I := -1; if not Search(KeyOf(Item), I) or Duplicates then AtInsert(I, Item); end; @@ -2036,6 +2046,7 @@ procedure TStringColl.FillEnum(Str: AnsiString; Delim: AnsiChar; begin while Str <> '' do begin + z := ''; GetWrd(Str, z, Delim); if Sorted then Ins(z) @@ -2048,6 +2059,7 @@ function TStringColl.Found(const Str: AnsiString): Boolean; var I: Integer; begin + I := -1; Result := Search(@Str, I); end; @@ -2307,6 +2319,7 @@ function TempFileName(const APath, APfx: AnsiString): AnsiString; Result := ''; Exit; end; + S := ''; SetLength(S, 1000); GetTempFileNameA(@(APath[1]), @(APfx[1]), 0, @(S[1])); Result := Copy(S, 1, NulSearch(S[1])); @@ -2502,6 +2515,8 @@ function ExpandFileName(const FileName: AnsiString): AnsiString; end else begin + FillChar(Buffer, SizeOf(Buffer), 0); + FName := nil; SetString(Result, Buffer, GetFullPathNameA(@(FileName[1]), SizeOf(Buffer), Buffer, FName)); end; @@ -2851,6 +2866,7 @@ function UnpackXchars(var S: AnsiString; P: Boolean): Boolean; begin Result := False; + R := ''; sl := Length(S); I := 0; while I < sl do @@ -2903,6 +2919,7 @@ function ProcessQuotes(var S: AnsiString): Boolean; c: AnsiChar; begin Result := False; + R := ''; KVC := False; for I := 1 to Length(S) do begin @@ -2948,6 +2965,7 @@ function _Val(const S: AnsiString; var V: Integer): Boolean; function StoI(const S: AnsiString): Integer; begin + Result := 0; if not _Val(S, Result) then Result := 0; end; @@ -2989,8 +3007,10 @@ procedure GetBias; T, L: TFileTime; a, B, c: DWORD; begin + FillChar(T, SizeOf(T), 0); + FillChar(L, SizeOf(L), 0); GetSystemTimeAsFileTime(T); - FileTimeToLocalFileTime(T, L); + if not FileTimeToLocalFileTime(T, L) then Exit; a := uCvtGetFileTime(T.dwLowDateTime, T.dwHighDateTime); B := uCvtGetFileTime(L.dwLowDateTime, L.dwHighDateTime); if a > B then @@ -3022,7 +3042,7 @@ THostCacheColl = class(TSortedColl) function THostCacheColl.Compare(Key1, Key2: Pointer): Integer; begin - Result := Integer(Key1) - Integer(Key2); + Result := NativeInt(Key1) - NativeInt(Key2); end; function THostCacheColl.KeyOf(Item: Pointer): Pointer; @@ -3041,6 +3061,7 @@ function GetHostNameByAddr(Addr: DWORD): AnsiString; HostName: AnsiString; begin HostCache.Enter; + I := -1; F := HostCache.Search(Pointer(Addr), I); if F then Result := StrAsg(THostCache(HostCache[I]).Name);