replaces old bzero() with memset().

This commit is contained in:
TLINDEN
2013-10-29 23:08:43 +01:00
parent 40a49cd76f
commit 58a3bca8d7
10 changed files with 13 additions and 21 deletions

1
TODO
View File

@@ -1,2 +1 @@
- always save vault to tmp, then validate it and copy if ok
- replace sys/endian.h by portable / configure

6
configure vendored
View File

@@ -12306,7 +12306,8 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
for ac_header in errno.h err.h stdlib.h string.h unistd.h stdio.h getopt.h\
limits.h stddef.h stdint.h sys/types.h sys/stat.h endian.h sys/endian.h termios.h
limits.h stddef.h stdint.h sys/types.h sys/stat.h endian.h \
sys/endian.h termios.h arpa/inet.h netinet/in.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -12335,7 +12336,6 @@ fi
# Checks for library functions.
for ac_func in \
arc4random_buf \
bzero \
fread \
fopen \
free \
@@ -12558,8 +12558,6 @@ fi
if test -n "$_ldlib"; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${_ldlib}"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: LD_LIBRARY_PATH: $LD_LIBRARY_PATH" >&5
$as_echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking is libsodium compiled correctly" >&5

View File

@@ -35,7 +35,6 @@ AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS( \
arc4random_buf \
bzero \
fread \
fopen \
free \
@@ -172,7 +171,6 @@ AC_CHECK_LIB(sodium, sodium_init, , [AC_MSG_ERROR([cannot link with -lsodium, in
if test -n "$_ldlib"; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${_ldlib}"
AC_MSG_RESULT([LD_LIBRARY_PATH: $LD_LIBRARY_PATH])
fi
AC_MSG_CHECKING([is libsodium compiled correctly])

View File

@@ -9,9 +9,6 @@
/* Define to 1 if you have the `be32toh' function. */
#undef HAVE_BE32TOH
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H

View File

@@ -52,7 +52,7 @@ pcp_key_t *pcpkey_encrypt(pcp_key_t *key, char *passphrase) {
es = pcp_sodium_mac(&encrypted, key->secret, 32, key->nonce, encryptkey);
bzero(encryptkey, 32);
memset(encryptkey, 0, 32);
free(encryptkey);
if(es == 48) {
@@ -77,7 +77,7 @@ pcp_key_t *pcpkey_decrypt(pcp_key_t *key, char *passphrase) {
es = pcp_sodium_verify_mac(&decrypted, key->encrypted, 48, key->nonce, encryptkey);
bzero(encryptkey, 32);
memset(encryptkey, 0, 32);
free(encryptkey);
if(es == 0) {
@@ -140,7 +140,7 @@ void pcp_cleanhashes() {
pcp_key_t *current_key, *tmp;
HASH_ITER(hh, pcpkey_hash, current_key, tmp) {
HASH_DEL(pcpkey_hash,current_key);
bzero(current_key, sizeof(pcp_key_t));
memset(current_key, 0, sizeof(pcp_key_t));
free(current_key); // FIXME: coredumps here after n-th secret keys has been added
}
}
@@ -149,7 +149,7 @@ void pcp_cleanhashes() {
pcp_pubkey_t *current_pub, *ptmp;
HASH_ITER(hh, pcppubkey_hash, current_pub, ptmp) {
HASH_DEL(pcppubkey_hash,current_pub);
bzero(current_pub, sizeof(pcp_pubkey_t));
memset(current_pub, 0, sizeof(pcp_pubkey_t));
free(current_pub);
}
}

View File

@@ -34,8 +34,8 @@ unsigned char *pcp_derivekey(char *passphrase) {
memcpy(key, xor, crypto_secretbox_KEYBYTES);
bzero(passphrase, plen);
bzero(temp, crypto_hash_BYTES);
memset(passphrase, 0, plen);
memset(temp, 0, crypto_hash_BYTES);
free(passphrase);
free(temp);
free(xor);

View File

@@ -11,7 +11,7 @@ void *ucmalloc(size_t s) {
exit(-1);
}
bzero (value, size);
memset (value, 0, size);
//printf("allocated %d bytes at %p\n", (int)size, value);

View File

@@ -124,7 +124,7 @@ int pcpvault_additem(vault_t *vault, void *item, size_t itemsize, uint8_t type,
fwrite(header, sizeof(vault_item_header_t), 1, vault->fd);
fwrite(saveitem, itemsize, 1, vault->fd);
bzero(saveitem, itemsize);
memset(saveitem, 0, itemsize);
free(saveitem);
if(do_hash == 1) {
@@ -223,7 +223,7 @@ unsigned char *pcpvault_create_checksum(vault_t *vault) {
crypto_hash_sha256(checksum, data, datasize);
bzero(data, datasize);
memset(data, 0, datasize);
free(data);
return checksum;

View File

@@ -11,7 +11,7 @@ unsigned char *pcp_padfour(unsigned char *src, size_t srclen, size_t *dstlen) {
dst = (unsigned char*)ucmalloc(outlen);
dst[0] = zerolen; // add the number of zeros we add
memcpy(&dst[1], src, srclen); // add the original
bzero(&dst[srclen+1], zerolen); // pad with zeroes
memset(&dst[srclen+1], 0, zerolen); // pad with zeroes
*dstlen = outlen;

View File

@@ -50,7 +50,7 @@ void mkinvv(const char *name, int type) {
header->fileid = PCP_VAULT_ID;
header->version = PCP_VAULT_VERSION;
bzero(header->checksum, 32);
memset(header->checksum, 0, 32);
item->version = PCP_KEY_VERSION;
item->type = PCP_KEY_TYPE_SECRET;