Re: [ros-diffs] 01/01: [ADVAPI32][SERVICES] Add (dummy) password encryption/decryption functions to CreateServiceA/W and ChangeServiceConfigA/W in order to prepare to pass encrypted passwords to the service manager
Pierre Schweitzer <[email protected]> Mon, 17 Sep 2018 22:15:16 +0200
| Newsgroups | gmane.os.reactos.kernel |
|---|---|
| Message-ID | <[email protected]> |
Hi Eric, For security reason, when freeing your password buffers (see below), you shouldn't be using ZeroMemory() before free, but SecureZeroMemory() to zero the buffer. The first one can be optimized (and thus removed) by the compiler. The second cannot. Cheers, Pierre Le 17/09/2018 à 16:36, Eric Kohl a écrit : > https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5e2c4657ca10dea1154cb43f16ee6962999ac7a4 > > commit 5e2c4657ca10dea1154cb43f16ee6962999ac7a4 > Author: Eric Kohl <[email protected]> > AuthorDate: Mon Sep 17 16:34:48 2018 +0200 > Commit: Eric Kohl <[email protected]> > CommitDate: Mon Sep 17 16:34:48 2018 +0200 > > [ADVAPI32][SERVICES] Add (dummy) password encryption/decryption functions to CreateServiceA/W and ChangeServiceConfigA/W in order to prepare to pass encrypted passwords to the service manager > --- > base/system/services/config.c | 24 ++++++++ > base/system/services/rpcserver.c | 49 ++++++++++++++-- > base/system/services/services.h | 7 +++ > dll/win32/advapi32/service/scm.c | 123 ++++++++++++++++++++++++++++++++------- > 4 files changed, 177 insertions(+), 26 deletions(-) > > diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c > index aa64233350..454181bb66 100644 > --- a/base/system/services/rpcserver.c > +++ b/base/system/services/rpcserver.c > @@ -2216,12 +2232,23 @@ RChangeServiceConfigW( > dwError = ERROR_SUCCESS; > > if (dwError != ERROR_SUCCESS) > + { > + DPRINT1("ScmSetServicePassword failed (Error %lu)\n", dwError); > goto done; > + } > } > } > } > > done: > + if (lpClearTextPassword != NULL) > + { > + /* Wipe and release the password buffer */ > + ZeroMemory(lpClearTextPassword, > + (wcslen(lpClearTextPassword) + 1) * sizeof(WCHAR)); > + HeapFree(GetProcessHeap(), 0, lpClearTextPassword); > + } > + > if (hServiceKey != NULL) > RegCloseKey(hServiceKey); > > @@ -2612,6 +2645,14 @@ done: > if (hServiceKey != NULL) > RegCloseKey(hServiceKey); > > + if (lpClearTextPassword != NULL) > + { > + /* Wipe and release the password buffer */ > + ZeroMemory(lpClearTextPassword, > + (wcslen(lpClearTextPassword) + 1) * sizeof(WCHAR)); > + HeapFree(GetProcessHeap(), 0, lpClearTextPassword); > + } > + > if (dwError == ERROR_SUCCESS) > { > DPRINT("hService %p\n", hServiceHandle); -- Pierre Schweitzer <pierre at reactos.org> System & Network Administrator Senior Kernel Developer ReactOS Deutschland e.V. _______________________________________________ Ros-dev mailing list [email protected] http://www.reactos.org/mailman/listinfo/ros-dev
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE+qe4Wfh6h6eUzdawdUVVbD1YWwsFAlugC1QACgkQdUVVbD1Y Wwv+Gw//UaAULRUafiAjSmhEtMTYqnJ+/QbYucelxIFIgHJCl+K69nBcxhRvf42G V7Q226NR6DuNouVC6vhcEpNxat7QGe8iK4i0/qzg07cPFi/1NOYbeVJcXSk829Dn UXS5OrwRXAhq83g50/v81hae35a4h3slmnswztiLLwN3YqPsemMADOrs/Ml8gZv/ fff/FP2HbKmc/Mt9N00Cnq7KopkZSU5Xggq1G5WTdRoztJ9ZKRVnEmzBNEfuwhsV f0WNDtkI0LrgHTBzdLlLwlWv3C+k5naET81yunlxamexIAZ/TlDVF0Wta9dOV/nY guxeT+NmG3s3KU2VqDA3nQj5zgDAgjZ7qGRTNZbbjI3mSLWROrz7MNvYRCuHeSBV +sCI58DYOffOOEM101ZkbULx44L/aRtlmeG1Oe0G/7mgaJw0g+Kq7EuRTYEv16uW It5C/sSAdvHwkAKGl3KcyeGjzX8rvfy+cKrggu4xA2AoJ1b9Ol2O306UF2vH5dtz klWxY0WADmCFi4hQyxfzto9EgaHKDRswPMJxV+3x/2iEj+Vkyy6U1DTEuX0eBu0T 9/hpGofUuCPZzde8t+DQzmM3AM7HUjd067t1p0oaWXAbwG60UNa6diz0xJNi1MuC PikwcZRz/4CZ0TFgbr74hli0pZ3rTbpSR+aYcuNVdKCwzYPHPQk= =9dAM -----END PGP SIGNATURE-----