# HG changeset patch # User Olaf Wintermann # Date 1694945284 -7200 # Node ID 38796c7e32b635910cfa07b9bcdc14c4b1048f32 # Parent 7110b37f2a6b1f44379cb7d55f3587e73d66777b fix aes_write on windows could write non-decrypted bytes to output buffer diff -r 7110b37f2a6b -r 38796c7e32b6 libidav/crypto.c --- a/libidav/crypto.c Sun Sep 17 11:21:31 2023 +0200 +++ b/libidav/crypto.c Sun Sep 17 12:08:04 2023 +0200 @@ -1093,10 +1093,11 @@ // ready to decrypt the message ULONG outlen = clen + 32; - unsigned char *out = malloc(outlen); // decrypt if(clen > 0) { + unsigned char* out = malloc(outlen); + ULONG enc_len = 0; ULONG status = BCryptDecrypt(dec->ctx.hKey, cbuf, clen, NULL, dec->ctx.pbIV, 16, out, outlen, &enc_len, 0); if(status > 0) { @@ -1106,13 +1107,14 @@ return 0; } outlen = enc_len; + + // write decrypted data to the output stream and update the hash + dec->write(out, 1, outlen, dec->stream); + BCryptHashData(dec->sha256.hHash, out, outlen, 0); + + free(out); } - // write decrypted data to the output stream and update the hash - dec->write(out, 1, outlen, dec->stream); - BCryptHashData(dec->sha256.hHash, out, outlen, 0); - - free(out); free(cbuf); return (s*n) / s; diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/dav-sync/dav-sync.vcxproj --- a/make/vs/dav-sync/dav-sync.vcxproj Sun Sep 17 11:21:31 2023 +0200 +++ b/make/vs/dav-sync/dav-sync.vcxproj Sun Sep 17 12:08:04 2023 +0200 @@ -72,7 +72,7 @@ $(SolutionDir)..\..\build\vs\$(Platform)\$(Configuration)\ - ..\..\..\build\vs\dav\$(Platform)\$(Configuration)\ + ..\..\..\build\vs\dav-sync\$(Platform)\$(Configuration)\ @@ -110,6 +110,8 @@ true ..\..\..\ucx;..\vcpkg_installed\x64-windows\x64-windows\include;..\..\..\;%(AdditionalIncludeDirectories) stdc17 + + Console diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/dav.sln --- a/make/vs/dav.sln Sun Sep 17 11:21:31 2023 +0200 +++ b/make/vs/dav.sln Sun Sep 17 12:08:04 2023 +0200 @@ -13,6 +13,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dav-sync", "dav-sync\dav-sync.vcxproj", "{961B8763-3587-4C28-9268-3970ED5FE106}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{EA9525DF-6935-41C6-8330-351AAD8555B8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -61,6 +63,14 @@ {961B8763-3587-4C28-9268-3970ED5FE106}.Release|x64.Build.0 = Release|x64 {961B8763-3587-4C28-9268-3970ED5FE106}.Release|x86.ActiveCfg = Release|Win32 {961B8763-3587-4C28-9268-3970ED5FE106}.Release|x86.Build.0 = Release|Win32 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Debug|x64.ActiveCfg = Debug|x64 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Debug|x64.Build.0 = Debug|x64 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Debug|x86.ActiveCfg = Debug|Win32 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Debug|x86.Build.0 = Debug|Win32 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Release|x64.ActiveCfg = Release|x64 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Release|x64.Build.0 = Release|x64 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Release|x86.ActiveCfg = Release|Win32 + {EA9525DF-6935-41C6-8330-351AAD8555B8}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/dav/dav.vcxproj --- a/make/vs/dav/dav.vcxproj Sun Sep 17 11:21:31 2023 +0200 +++ b/make/vs/dav/dav.vcxproj Sun Sep 17 12:08:04 2023 +0200 @@ -110,6 +110,8 @@ true ..\..\..\ucx;..\vcpkg_installed\x64-windows\x64-windows\include;..\..\..\;%(AdditionalIncludeDirectories) stdc17 + + Console diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/davcommon/davcommon.vcxproj --- a/make/vs/davcommon/davcommon.vcxproj Sun Sep 17 11:21:31 2023 +0200 +++ b/make/vs/davcommon/davcommon.vcxproj Sun Sep 17 12:08:04 2023 +0200 @@ -113,6 +113,8 @@ true ..\..\..\ucx;..\vcpkg_installed\x64-windows\x64-windows\include;..\..\..\;%(AdditionalIncludeDirectories) stdc17 + + Console diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/libidav/libidav.vcxproj --- a/make/vs/libidav/libidav.vcxproj Sun Sep 17 11:21:31 2023 +0200 +++ b/make/vs/libidav/libidav.vcxproj Sun Sep 17 12:08:04 2023 +0200 @@ -114,6 +114,8 @@ true stdc11 ..\..\..\ucx;..\vcpkg_installed\x64-windows\x64-windows\include + + Console diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/test/test.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/vs/test/test.vcxproj Sun Sep 17 12:08:04 2023 +0200 @@ -0,0 +1,161 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {ea9525df-6935-41c6-8330-351aad8555b8} + test + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\..\build\vs\$(Platform)\$(Configuration)\ + ..\..\..\build\vs\test\$(Platform)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + ..\..\..\ucx;..\vcpkg_installed\x64-windows\x64-windows\include;..\..\..\;%(AdditionalIncludeDirectories) + stdc17 + + + + + Console + true + ..\vcpkg_installed\x64-windows\x64-windows\lib;%(AdditionalLibraryDirectories) + charset.lib;iconv.lib;libcurl.lib;libxml2.lib;lzma.lib;zlib.lib;bcrypt.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + {c29c0378-6548-48e8-9426-31922515212a} + + + {27da0164-3475-43e2-a1a4-a5d07d305749} + + + + + + \ No newline at end of file diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/test/test.vcxproj.filters --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/vs/test/test.vcxproj.filters Sun Sep 17 12:08:04 2023 +0200 @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + Quelldateien + + + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + \ No newline at end of file diff -r 7110b37f2a6b -r 38796c7e32b6 make/vs/ucx/ucx.vcxproj --- a/make/vs/ucx/ucx.vcxproj Sun Sep 17 11:21:31 2023 +0200 +++ b/make/vs/ucx/ucx.vcxproj Sun Sep 17 12:08:04 2023 +0200 @@ -109,6 +109,8 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdc17 + + Console