Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
70587136
Commit
70587136
authored
Jun 17, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1654 from yorah/memzero
Memzero stuffs
parents
824cf80f
0525fb7e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
src/transports/cred.c
+2
-2
src/util.c
+0
-9
src/util.h
+11
-1
No files found.
src/transports/cred.c
View file @
70587136
...
...
@@ -17,7 +17,7 @@ static void plaintext_free(struct git_cred *cred)
git__free
(
c
->
username
);
/* Zero the memory which previously held the password */
memset
(
c
->
password
,
0x0
,
pass_len
);
git__memzero
(
c
->
password
,
pass_len
);
git__free
(
c
->
password
);
memset
(
c
,
0
,
sizeof
(
*
c
));
...
...
@@ -73,7 +73,7 @@ static void ssh_keyfile_passphrase_free(struct git_cred *cred)
if
(
c
->
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
);
}
...
...
src/util.c
View file @
70587136
...
...
@@ -722,12 +722,3 @@ void git__insertsort_r(
if
(
freeswap
)
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
;
}
src/util.h
View file @
70587136
...
...
@@ -325,6 +325,16 @@ extern size_t git__unescape(char *str);
* Safely zero-out memory, making sure that the compiler
* 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__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment