mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-08 00:57:19 +00:00
commit
705871364b
@ -17,7 +17,7 @@ static void plaintext_free(struct git_cred *cred)
|
|||||||
git__free(c->username);
|
git__free(c->username);
|
||||||
|
|
||||||
/* Zero the memory which previously held the password */
|
/* Zero the memory which previously held the password */
|
||||||
memset(c->password, 0x0, pass_len);
|
git__memzero(c->password, pass_len);
|
||||||
git__free(c->password);
|
git__free(c->password);
|
||||||
|
|
||||||
memset(c, 0, sizeof(*c));
|
memset(c, 0, sizeof(*c));
|
||||||
@ -73,7 +73,7 @@ static void ssh_keyfile_passphrase_free(struct git_cred *cred)
|
|||||||
|
|
||||||
if (c->passphrase) {
|
if (c->passphrase) {
|
||||||
/* Zero the memory which previously held the passphrase */
|
/* Zero the memory which previously held the passphrase */
|
||||||
memset(c->passphrase, 0x0, pass_len);
|
git__memzero(c->passphrase, pass_len);
|
||||||
git__free(c->passphrase);
|
git__free(c->passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,12 +722,3 @@ void git__insertsort_r(
|
|||||||
if (freeswap)
|
if (freeswap)
|
||||||
git__free(swapel);
|
git__free(swapel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void git__memzero(volatile void *data, size_t size)
|
|
||||||
{
|
|
||||||
volatile uint8_t *scan = data;
|
|
||||||
uint8_t *end = scan + size;
|
|
||||||
|
|
||||||
while (scan < end)
|
|
||||||
*scan++ = 0x0;
|
|
||||||
}
|
|
||||||
|
12
src/util.h
12
src/util.h
@ -325,6 +325,16 @@ extern size_t git__unescape(char *str);
|
|||||||
* Safely zero-out memory, making sure that the compiler
|
* Safely zero-out memory, making sure that the compiler
|
||||||
* doesn't optimize away the operation.
|
* doesn't optimize away the operation.
|
||||||
*/
|
*/
|
||||||
extern void git__memzero(volatile void *data, size_t size);
|
GIT_INLINE(void) git__memzero(void *data, size_t size)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
SecureZeroMemory((PVOID)data, size);
|
||||||
|
#else
|
||||||
|
volatile uint8_t *scan = (volatile uint8_t *)data;
|
||||||
|
|
||||||
|
while (size--)
|
||||||
|
*scan++ = 0x0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* INCLUDE_util_h__ */
|
#endif /* INCLUDE_util_h__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user