2
0

More standard memset_s

This commit is contained in:
Maarten Billemont
2017-09-25 02:53:34 -04:00
parent f2ae35080d
commit 6b554c67ed
7 changed files with 38 additions and 27 deletions

View File

@@ -138,7 +138,7 @@ cc() {
if hash llvm-gcc 2>/dev/null; then
llvm-gcc "$@"
elif hash gcc 2>/dev/null; then
gcc -std=gnu99 "$@"
gcc -std=c11 "$@"
elif hash clang 2>/dev/null; then
clang "$@"
else

View File

@@ -41,6 +41,7 @@
#include "blf.h"
#include "blowfish.h"
#include "mpw-util.h"
/* This implementation is adaptable to current computing power.
* You can have up to 2^31 rounds which should be enough for some
@@ -186,10 +187,10 @@ bcrypt_hashpass(const char *key, const uint8_t *salt, char *encrypted,
snprintf( encrypted, 8, "$2%c$%2.2u$", minor, logr );
encode_base64( encrypted + 7, csalt, BCRYPT_MAXSALT );
encode_base64( encrypted + 7 + 22, ciphertext, 4 * BCRYPT_WORDS - 1 );
memset_s( &state, sizeof state, 0, sizeof state );
memset_s( ciphertext, sizeof ciphertext, 0, sizeof ciphertext );
memset_s( csalt, sizeof csalt, 0, sizeof csalt );
memset_s( cdata, sizeof cdata, 0, sizeof cdata );
mpw_zero( &state, sizeof state );
mpw_zero( ciphertext, sizeof ciphertext );
mpw_zero( csalt, sizeof csalt );
mpw_zero( cdata, sizeof cdata );
return 0;
inval:

View File

@@ -128,7 +128,7 @@ const char *mpw_getpass(const char *prompt) {
return NULL;
password = strdup( answer );
memset_s( answer, strlen( answer ), 0, strlen( answer ) );
mpw_zero( answer, strlen( answer ) );
return password;
}

View File

@@ -273,7 +273,7 @@ void cli_free(Arguments *args, Operation *operation) {
void cli_args(Arguments *args, Operation *operation, const int argc, char *const argv[]) {
for (int opt; (opt = getopt( argc, argv, "u:U:m:M:t:P:c:a:p:C:f:F:R:vqh" )) != EOF;
optarg? memset_s( optarg, strlen( optarg ), 0, strlen( optarg ) ): 0)
optarg? mpw_zero( optarg, strlen( optarg ) ): NULL)
switch (opt) {
case 'u':
args->fullName = optarg && strlen( optarg )? strdup( optarg ): NULL;