Skip to content

Commit

Permalink
Merge branch 'pr-160'
Browse files Browse the repository at this point in the history
  • Loading branch information
klali committed Apr 28, 2020
2 parents c1c937f + 13f6944 commit fa5cf5a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ykpers-args.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, char *oathid,
else if (strncmp(optarg, "uid", 3) == 0) {
char *uid = optarg+4;
size_t uidlen;
unsigned char uidbin[256];
unsigned char uidbin[256] = {0};
size_t uidbinlen = 0;
int rc;
char *uidtmp = NULL;
Expand Down Expand Up @@ -787,7 +787,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, char *oathid,
size_t key_bytes = (size_t)ykp_get_supported_key_length(cfg);
int res = 0;
char *key_tmp = NULL;
char keybuf[20];
char keybuf[20] = {0};

if(keylocation == 2) {
const char *prompt = " AES key, 16 bytes (32 characters hex) : ";
Expand Down Expand Up @@ -865,7 +865,7 @@ int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, char *oathid,
static int _set_fixed(char *opt, YKP_CONFIG *cfg) {
const char *fixed = opt;
size_t fixedlen = strlen (fixed);
unsigned char fixedbin[256];
unsigned char fixedbin[256] = {0};
size_t fixedbinlen = 0;
int rc = hex_modhex_decode(fixedbin, &fixedbinlen,
fixed, fixedlen,
Expand Down Expand Up @@ -898,7 +898,7 @@ static int _format_decimal_as_hex(uint8_t *dst, size_t dst_len, uint8_t *src)
/* For details, see YubiKey Manual 2010-09-16 section 5.3.4 - OATH-HOTP Token Identifier */
static int _format_oath_id(uint8_t *dst, size_t dst_len, uint8_t vendor, uint8_t type, uint32_t mui)
{
uint8_t buf[8 + 1];
uint8_t buf[8 + 1] = {0};

if (mui > 99999999)
return 0;
Expand Down
14 changes: 8 additions & 6 deletions ykpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ int ykp_get_supported_key_length(const YKP_CONFIG *cfg)

/* Decode 128 bit AES key into cfg->ykcore_config.key */
int ykp_AES_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
char aesbin[256];
char aesbin[256] = {0};

/* Make sure that the hexkey is exactly 32 characters */
if (strlen(hexkey) != 32) {
Expand All @@ -280,6 +280,7 @@ int ykp_AES_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {

yubikey_hex_decode(aesbin, hexkey, sizeof(aesbin));
memcpy(cfg->ykcore_config.key, aesbin, sizeof(cfg->ykcore_config.key));
insecure_memzero (aesbin, sizeof(aesbin));

return 0;
}
Expand Down Expand Up @@ -311,7 +312,7 @@ int ykp_HMAC_key_from_raw(YKP_CONFIG *cfg, const char *key) {
* and 32 bits into the first four bytes of cfg->ykcore_config.uid.
*/
int ykp_HMAC_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
char aesbin[256];
char aesbin[256] = {0};
size_t i;

/* Make sure that the hexkey is exactly 40 characters */
Expand All @@ -330,6 +331,7 @@ int ykp_HMAC_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
i = sizeof(cfg->ykcore_config.key);
memcpy(cfg->ykcore_config.key, aesbin, i);
memcpy(cfg->ykcore_config.uid, aesbin + i, 20 - i);
insecure_memzero (aesbin, sizeof(aesbin));

return 0;
}
Expand All @@ -351,9 +353,9 @@ int ykp_AES_key_from_passphrase(YKP_CONFIG *cfg, const char *passphrase,
0
};
const char **random_place;
uint8_t _salt[8];
uint8_t _salt[8] = {0};
size_t _salt_len = 0;
unsigned char buf[sizeof(cfg->ykcore_config.key) + 4];
unsigned char buf[sizeof(cfg->ykcore_config.key) + 4] = {0};
int rc;
int key_bytes = ykp_get_supported_key_length(cfg);
YK_PRF_METHOD prf_method = {20, yk_hmac_sha1};
Expand Down Expand Up @@ -931,7 +933,7 @@ static const char str_extended_flags[] = "extended_flags";

static int _ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len) {
if (cfg) {
char buffer[256];
char buffer[256] = {0};
struct map_st *p;
unsigned char t_flags;
bool key_bits_in_uid = false;
Expand Down Expand Up @@ -1131,7 +1133,7 @@ int ykp_write_config(const YKP_CONFIG *cfg,
void *userdata),
void *userdata) {
if(cfg) {
char buffer[1024];
char buffer[1024] = {0};
int ret = _ykp_legacy_export_config(cfg, buffer, 1024);
if(ret) {
writer(buffer, strlen(buffer), userdata);
Expand Down
13 changes: 7 additions & 6 deletions ykpersonalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ int main(int argc, char **argv)
FILE *outf = NULL; const char *outfname = NULL;
int data_format = YKP_FORMAT_LEGACY;
bool verbose = false;
unsigned char access_code[256];
unsigned char access_code[256] = {0};
char *acc_code = NULL;
char *new_acc_code = NULL;
unsigned char scan_codes[sizeof(SCAN_MAP)];
unsigned char device_info[128];
unsigned char scan_codes[sizeof(SCAN_MAP)] = {0};
unsigned char device_info[128] = {0};
size_t device_info_len = 0;
YK_KEY *yk = 0;
YKP_CONFIG *cfg = ykp_alloc();
YK_STATUS *st = ykds_alloc();
bool autocommit = false;
char data[1024];
char data[1024] = {0};
bool dry_run = false;

/* Options */
Expand Down Expand Up @@ -184,7 +184,7 @@ int main(int argc, char **argv)
}
}
if(new_acc_code) {
unsigned char accbin[256];
unsigned char accbin[256] = {0};
size_t accbinlen = 0;
int rc = hex_modhex_decode (accbin, &accbinlen,
new_acc_code, strlen(new_acc_code),
Expand Down Expand Up @@ -261,7 +261,8 @@ int main(int argc, char **argv)
goto err;
}
} else {
char commitbuf[256]; size_t commitlen;
char commitbuf[256] = {0};
size_t commitlen;

if (ykp_command(cfg) == SLOT_SWAP) {
fprintf(stderr, "Configuration in slot 1 and 2 will be swapped\n");
Expand Down

0 comments on commit fa5cf5a

Please sign in to comment.