legacy: explicitly initialize variables

pull/607/head
Ondřej Vejpustek 5 years ago committed by Pavol Rusnak
parent 5401f88d52
commit 08265cdd08
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -35,7 +35,7 @@
#include "util.h"
void layoutFirmwareFingerprint(const uint8_t *hash) {
char str[4][17];
char str[4][17] = {0};
for (int i = 0; i < 4; i++) {
data2hex(hash + i * 8, 8, str[i]);
}
@ -129,7 +129,7 @@ int main(void) {
const image_header *hdr =
(const image_header *)FLASH_PTR(FLASH_FWHEADER_START);
uint8_t fingerprint[32];
uint8_t fingerprint[32] = {0};
int signed_firmware = signatures_new_ok(hdr, fingerprint);
if (SIG_OK != signed_firmware) {
show_unofficial_warning(fingerprint);

@ -79,7 +79,7 @@ int signatures_old_ok(void) {
return false;
}
uint8_t hash[32];
uint8_t hash[32] = {0};
sha256_Raw(FLASH_PTR(FLASH_OLD_APP_START), codelen, hash);
if (sigindex1 < 1 || sigindex1 > PUBKEYS) return SIG_FAIL; // invalid index
@ -110,7 +110,7 @@ int signatures_old_ok(void) {
}
void compute_firmware_fingerprint(const image_header *hdr, uint8_t hash[32]) {
image_header copy;
image_header copy = {0};
memcpy(&copy, hdr, sizeof(image_header));
memzero(copy.sig1, sizeof(copy.sig1));
memzero(copy.sig2, sizeof(copy.sig2));
@ -137,7 +137,7 @@ bool firmware_present_new(void) {
}
int signatures_new_ok(const image_header *hdr, uint8_t store_fingerprint[32]) {
uint8_t hash[32];
uint8_t hash[32] = {0};
compute_firmware_fingerprint(hdr, hash);
if (store_fingerprint) {
@ -179,7 +179,7 @@ int mem_is_empty(const uint8_t *src, uint32_t len) {
}
int check_firmware_hashes(const image_header *hdr) {
uint8_t hash[32];
uint8_t hash[32] = {0};
// check hash of the first code chunk
sha256_Raw(FLASH_PTR(FLASH_APP_START), (64 - 1) * 1024, hash);
if (0 != memcmp(hash, hdr->hashes, 32)) return SIG_FAIL;

@ -66,8 +66,8 @@ static void check_and_write_chunk(void) {
if (chunk_pos == 0) {
chunk_pos = FW_CHUNK_SIZE;
}
uint8_t hash[32];
SHA256_CTX ctx;
uint8_t hash[32] = {0};
SHA256_CTX ctx = {0};
sha256_Init(&ctx);
sha256_Update(&ctx, (const uint8_t *)FW_CHUNK + offset, chunk_pos - offset);
if (chunk_pos < 64 * 1024) {
@ -329,7 +329,7 @@ static void rx_callback(usbd_device *dev, uint8_t ep) {
if (msg_id != 0x001B) { // ButtonAck message (id 27)
return;
}
uint8_t hash[32];
uint8_t hash[32] = {0};
compute_firmware_fingerprint(hdr, hash);
layoutFirmwareFingerprint(hash);
hash_check_ok = get_button_response();
@ -347,7 +347,7 @@ static void rx_callback(usbd_device *dev, uint8_t ep) {
// erase storage
erase_storage();
// check erasure
uint8_t hash[32];
uint8_t hash[32] = {0};
sha256_Raw(FLASH_PTR(FLASH_STORAGE_START), FLASH_STORAGE_LEN, hash);
if (memcmp(hash,
"\x2d\x86\x4c\x0b\x78\x9a\x43\x21\x4e\xee\x85\x24\xd3\x18\x20"

@ -103,7 +103,7 @@ void wait_random(void) {
}
void drbg_init() {
uint8_t entropy[48];
uint8_t entropy[48] = {0};
random_buffer(entropy, sizeof(entropy));
hmac_drbg_init(&drbg_ctx, entropy, sizeof(entropy), NULL, 0);
}
@ -117,7 +117,7 @@ void drbg_generate(uint8_t *buf, size_t len) {
}
uint32_t drbg_random32(void) {
uint32_t value;
uint32_t value = 0;
drbg_generate((uint8_t *)&value, sizeof(value));
return value;
}

@ -35,9 +35,9 @@ int frame = 0;
uint8_t seed[128];
uint8_t *pass = (uint8_t *)"meadow";
uint32_t passlen;
uint32_t passlen = 0;
uint8_t *salt = (uint8_t *)"TREZOR";
uint32_t saltlen;
uint32_t saltlen = 0;
static const struct usb_device_descriptor dev_descr = {
.bLength = USB_DT_DEVICE_SIZE,

@ -21,7 +21,7 @@
uint32_t random32(void) {
static uint32_t last = 0;
uint32_t new;
uint32_t new = 0;
do {
emulatorRandom(&new, sizeof(new));

@ -57,7 +57,7 @@ void __attribute__((noreturn)) shutdown(void) {
}
void emulatorRandom(void *buffer, size_t size) {
ssize_t n, len = 0;
ssize_t n = 0, len = 0;
do {
n = read(random_fd, (char *)buffer + len, size - len);
if (n < 0) {

@ -24,7 +24,7 @@
void timer_init(void) {}
uint32_t timer_ms(void) {
struct timespec t;
struct timespec t = {0};
clock_gettime(CLOCK_MONOTONIC, &t);
uint32_t msec = t.tv_sec * 1000 + (t.tv_nsec / 1000000);

@ -42,7 +42,7 @@ static int socket_setup(int port) {
exit(1);
}
struct sockaddr_in addr;
struct sockaddr_in addr = {0};
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);

@ -132,7 +132,7 @@ static int known_bootloader(int r, const uint8_t *hash) {
void check_bootloader(void) {
#if MEMORY_PROTECT
uint8_t hash[32];
uint8_t hash[32] = {0};
int r = memory_bootloader_hash(hash);
if (!known_bootloader(r, hash)) {

@ -54,7 +54,7 @@ const CoinInfo *coinBySlip44(uint32_t coin_type) {
bool coinExtractAddressType(const CoinInfo *coin, const char *addr,
uint32_t *address_type) {
if (!addr) return false;
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
uint8_t addr_raw[MAX_ADDR_RAW_SIZE] = {0};
int len = base58_decode_check(addr, coin->curve->hasher_base58, addr_raw,
MAX_ADDR_RAW_SIZE);
if (len >= 21) {

@ -85,7 +85,7 @@ static const uint32_t PIN_EMPTY = 1;
static uint32_t config_uuid[UUID_SIZE / sizeof(uint32_t)];
_Static_assert(sizeof(config_uuid) == UUID_SIZE, "config_uuid has wrong size");
char config_uuid_str[2 * UUID_SIZE + 1];
char config_uuid_str[2 * UUID_SIZE + 1] = {0};
/*
Old storage layout:
@ -439,7 +439,7 @@ static void config_compute_u2froot(const char *mnemonic,
}
static void config_setNode(const HDNodeType *node) {
StorageHDNode storageHDNode;
StorageHDNode storageHDNode = {0};
memzero(&storageHDNode, sizeof(storageHDNode));
storageHDNode.depth = node->depth;
@ -463,7 +463,7 @@ static void config_setNode(const HDNodeType *node) {
bool config_dumpNode(HDNodeType *node) {
memzero(node, sizeof(HDNodeType));
StorageHDNode storageNode;
StorageHDNode storageNode = {0};
uint16_t len = 0;
if (sectrue !=
storage_get(KEY_NODE, &storageNode, sizeof(storageNode), &len) ||
@ -571,7 +571,7 @@ const uint8_t *config_getSeed(bool usePassphrase) {
}
// if storage has mnemonic, convert it to node and use it
char mnemonic[MAX_MNEMONIC_LEN + 1];
char mnemonic[MAX_MNEMONIC_LEN + 1] = {0};
if (config_getMnemonic(mnemonic, sizeof(mnemonic))) {
if (usePassphrase && !protectPassphrase()) {
memzero(mnemonic, sizeof(mnemonic));
@ -607,7 +607,7 @@ static bool config_loadNode(const StorageHDNode *node, const char *curve,
}
bool config_getU2FRoot(HDNode *node) {
StorageHDNode u2fNode;
StorageHDNode u2fNode = {0};
uint16_t len = 0;
if (sectrue != storage_get(KEY_U2F_ROOT, &u2fNode, sizeof(u2fNode), &len) ||
len != sizeof(StorageHDNode)) {
@ -621,7 +621,7 @@ bool config_getU2FRoot(HDNode *node) {
bool config_getRootNode(HDNode *node, const char *curve, bool usePassphrase) {
// if storage has node, decrypt and use it
StorageHDNode storageHDNode;
StorageHDNode storageHDNode = {0};
uint16_t len = 0;
if (strcmp(curve, SECP256K1_NAME) == 0 &&
sectrue ==
@ -640,8 +640,8 @@ bool config_getRootNode(HDNode *node, const char *curve, bool usePassphrase) {
if (passphrase_protection && sectrue == sessionPassphraseCached &&
sessionPassphrase[0] != '\0') {
// decrypt hd node
uint8_t secret[64];
PBKDF2_HMAC_SHA512_CTX pctx;
uint8_t secret[64] = {0};
PBKDF2_HMAC_SHA512_CTX pctx = {0};
char oldTiny = usbTiny(1);
pbkdf2_hmac_sha512_Init(&pctx, (const uint8_t *)sessionPassphrase,
strlen(sessionPassphrase),
@ -654,7 +654,7 @@ bool config_getRootNode(HDNode *node, const char *curve, bool usePassphrase) {
}
pbkdf2_hmac_sha512_Final(&pctx, secret);
usbTiny(oldTiny);
aes_decrypt_ctx ctx;
aes_decrypt_ctx ctx = {0};
aes_decrypt_key256(secret, &ctx);
aes_cbc_decrypt(node->chain_code, node->chain_code, 32, secret + 32,
&ctx);
@ -700,7 +700,7 @@ bool config_setMnemonic(const char *mnemonic) {
return false;
}
StorageHDNode u2fNode;
StorageHDNode u2fNode = {0};
memzero(&u2fNode, sizeof(u2fNode));
config_compute_u2froot(mnemonic, &u2fNode);
secbool ret = storage_set(KEY_U2F_ROOT, &u2fNode, sizeof(u2fNode));
@ -730,18 +730,18 @@ bool config_getMnemonic(char *dest, uint16_t dest_size) {
*/
bool config_containsMnemonic(const char *mnemonic) {
uint16_t len = 0;
uint8_t stored_mnemonic[MAX_MNEMONIC_LEN];
uint8_t stored_mnemonic[MAX_MNEMONIC_LEN] = {0};
if (sectrue != storage_get(KEY_MNEMONIC, stored_mnemonic,
sizeof(stored_mnemonic), &len)) {
return false;
}
// Compare the digests to mitigate side-channel attacks.
uint8_t digest_stored[SHA256_DIGEST_LENGTH];
uint8_t digest_stored[SHA256_DIGEST_LENGTH] = {0};
sha256_Raw(stored_mnemonic, len, digest_stored);
memzero(stored_mnemonic, sizeof(stored_mnemonic));
uint8_t digest_input[SHA256_DIGEST_LENGTH];
uint8_t digest_input[SHA256_DIGEST_LENGTH] = {0};
sha256_Raw((const uint8_t *)mnemonic, strnlen(mnemonic, MAX_MNEMONIC_LEN),
digest_input);
@ -823,7 +823,7 @@ bool session_getState(const uint8_t *salt, uint8_t *state,
}
// state[0:32] = salt
// state[32:64] = HMAC(passphrase, salt || device_id)
HMAC_SHA256_CTX ctx;
HMAC_SHA256_CTX ctx = {0};
hmac_sha256_Init(&ctx, (const uint8_t *)passphrase, strlen(passphrase));
hmac_sha256_Update(&ctx, state, 32);
hmac_sha256_Update(&ctx, (const uint8_t *)config_uuid, sizeof(config_uuid));

@ -124,11 +124,11 @@ int signifyMessageSign(HDNode *node, const uint8_t *message, size_t message_len,
static void cryptoMessageHash(const CoinInfo *coin, const uint8_t *message,
size_t message_len,
uint8_t hash[HASHER_DIGEST_LENGTH]) {
Hasher hasher;
Hasher hasher = {0};
hasher_Init(&hasher, coin->curve->hasher_sign);
hasher_Update(&hasher, (const uint8_t *)coin->signed_message_header,
strlen(coin->signed_message_header));
uint8_t varint[5];
uint8_t varint[5] = {0};
uint32_t l = ser_length(message_len, varint);
hasher_Update(&hasher, varint, l);
hasher_Update(&hasher, message, message_len);
@ -138,10 +138,10 @@ static void cryptoMessageHash(const CoinInfo *coin, const uint8_t *message,
int cryptoMessageSign(const CoinInfo *coin, HDNode *node,
InputScriptType script_type, const uint8_t *message,
size_t message_len, uint8_t *signature) {
uint8_t hash[HASHER_DIGEST_LENGTH];
uint8_t hash[HASHER_DIGEST_LENGTH] = {0};
cryptoMessageHash(coin, message, message_len, hash);
uint8_t pby;
uint8_t pby = 0;
int result = hdnode_sign_digest(node, hash, signature + 1, &pby, NULL);
if (result == 0) {
switch (script_type) {
@ -170,14 +170,14 @@ int cryptoMessageVerify(const CoinInfo *coin, const uint8_t *message,
return 1;
}
uint8_t hash[HASHER_DIGEST_LENGTH];
uint8_t hash[HASHER_DIGEST_LENGTH] = {0};
cryptoMessageHash(coin, message, message_len, hash);
uint8_t recid = (signature[0] - 27) % 4;
bool compressed = signature[0] >= 31;
// check if signature verifies the digest and recover the public key
uint8_t pubkey[65];
uint8_t pubkey[65] = {0};
if (ecdsa_recover_pub_from_sig(coin->curve->params, pubkey, signature + 1,
hash, recid) != 0) {
return 3;
@ -188,12 +188,12 @@ int cryptoMessageVerify(const CoinInfo *coin, const uint8_t *message,
}
// check if the address is correct
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
uint8_t recovered_raw[MAX_ADDR_RAW_SIZE];
uint8_t addr_raw[MAX_ADDR_RAW_SIZE] = {0};
uint8_t recovered_raw[MAX_ADDR_RAW_SIZE] = {0};
// p2pkh
if (signature[0] >= 27 && signature[0] <= 34) {
size_t len;
size_t len = 0;
if (coin->cashaddr_prefix) {
if (!cash_addr_decode(addr_raw, &len, coin->cashaddr_prefix, address)) {
return 2;
@ -223,8 +223,8 @@ int cryptoMessageVerify(const CoinInfo *coin, const uint8_t *message,
} else
// segwit
if (signature[0] >= 39 && signature[0] <= 42) {
int witver;
size_t len;
int witver = 0;
size_t len = 0;
if (!coin->bech32_prefix ||
!segwit_addr_decode(&witver, recovered_raw, &len, coin->bech32_prefix,
address)) {
@ -248,7 +248,7 @@ msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t
*privkey, const uint8_t *address_raw)
{
if (privkey && address_raw) { // signing == true
HDNode node;
HDNode node = {0};
payload[0] = display_only ? 0x81 : 0x01;
uint32_t l = ser_length(msg_size, payload + 1);
memcpy(payload + 1 + l, msg, msg_size);
@ -265,8 +265,8 @@ msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t
*payload_len = 1 + l + msg_size;
}
// generate random nonce
curve_point R;
bignum256 k;
curve_point R = {0};
bignum256 k = {0};
if (generate_k_random(&secp256k1, &k) != 0) {
return 2;
}
@ -277,23 +277,23 @@ msg_size, bool display_only, uint8_t *nonce, size_t *nonce_len, uint8_t
*nonce_len = 33;
// compute shared secret
point_multiply(&secp256k1, &k, pubkey, &R);
uint8_t shared_secret[33];
uint8_t shared_secret[33] = {0};
shared_secret[0] = 0x02 | (R.y.val[0] & 0x01);
bn_write_be(&R.x, shared_secret + 1);
// generate keying bytes
uint8_t keying_bytes[80];
uint8_t salt[22 + 33];
uint8_t keying_bytes[80] = {0};
uint8_t salt[22 + 33] = {0};
memcpy(salt, "Bitcoin Secure Message", 22);
memcpy(salt + 22, nonce, 33);
pbkdf2_hmac_sha256(shared_secret, 33, salt, 22 + 33, 2048, keying_bytes,
80);
// encrypt payload
aes_encrypt_ctx ctx;
aes_encrypt_ctx ctx = {0};
aes_encrypt_key256(keying_bytes, &ctx);
aes_cfb_encrypt(payload, payload, *payload_len, keying_bytes + 64,
&ctx);
// compute hmac
uint8_t out[32];
uint8_t out[32] = {0};
hmac_sha256(keying_bytes + 32, 32, payload, *payload_len, out);
memcpy(hmac, out, 8);
*hmac_len = 8;
@ -310,29 +310,29 @@ uint8_t *msg, size_t *msg_len, bool *display_only, bool *signing, uint8_t
return 1;
}
// compute shared secret
curve_point R;
bignum256 k;
curve_point R = {0};
bignum256 k = {0};
bn_read_be(privkey, &k);
point_multiply(&secp256k1, &k, nonce, &R);
uint8_t shared_secret[33];
uint8_t shared_secret[33] = {0};
shared_secret[0] = 0x02 | (R.y.val[0] & 0x01);
bn_write_be(&R.x, shared_secret + 1);
// generate keying bytes
uint8_t keying_bytes[80];
uint8_t salt[22 + 33];
uint8_t keying_bytes[80] = {0};
uint8_t salt[22 + 33] = {0};
memcpy(salt, "Bitcoin Secure Message", 22);
salt[22] = 0x02 | (nonce->y.val[0] & 0x01);
bn_write_be(&(nonce->x), salt + 23);
pbkdf2_hmac_sha256(shared_secret, 33, salt, 22 + 33, 2048, keying_bytes,
80);
// compute hmac
uint8_t out[32];
uint8_t out[32] = {0};
hmac_sha256(keying_bytes + 32, 32, payload, payload_len, out);
if (memcmp(hmac, out, 8) != 0) {
return 2;
}
// decrypt payload
aes_encrypt_ctx ctx;
aes_encrypt_ctx ctx = {0};
aes_encrypt_key256(keying_bytes, &ctx);
aes_cfb_decrypt(payload, payload, payload_len, keying_bytes + 64, &ctx);
// check first byte
@ -341,7 +341,7 @@ payload[0] != 0x81) { return 3;
}
*signing = payload[0] & 0x01;
*display_only = payload[0] & 0x80;
uint32_t l, o;
uint32_t l = 0; uint32_t o = 0;
l = deser_length(payload + 1, &o);
if (*signing) {
// FIXME: assumes a raw address is 21 bytes (also below).
@ -367,9 +367,9 @@ payload + 1 + l + o + 21) != 0) { return 5;
const HDNode *cryptoMultisigPubkey(const CoinInfo *coin,
const MultisigRedeemScriptType *multisig,
uint32_t index) {
const HDNodeType *node_ptr;
const uint32_t *address_n;
uint32_t address_n_count;
const HDNodeType *node_ptr = NULL;
const uint32_t *address_n = NULL;
uint32_t address_n_count = 0;
if (multisig->nodes_count) { // use multisig->nodes
if (index >= multisig->nodes_count) {
return 0;
@ -458,7 +458,7 @@ int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig,
}
}
// hash sorted nodes
SHA256_CTX ctx;
SHA256_CTX ctx = {0};
sha256_Init(&ctx);
sha256_Update(&ctx, (const uint8_t *)&(multisig->m), sizeof(uint32_t));
for (uint32_t i = 0; i < n; i++) {
@ -478,7 +478,7 @@ int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig,
}
int cryptoIdentityFingerprint(const IdentityType *identity, uint8_t *hash) {
SHA256_CTX ctx;
SHA256_CTX ctx = {0};
sha256_Init(&ctx);
sha256_Update(&ctx, (const uint8_t *)&(identity->index), sizeof(uint32_t));
if (identity->has_proto && identity->proto[0]) {

@ -46,7 +46,7 @@ static EthereumTxRequest msg_tx_request;
static CONFIDENTIAL uint8_t privkey[32];
static uint32_t chain_id;
static uint32_t tx_type;
struct SHA3_CTX keccak_ctx;
struct SHA3_CTX keccak_ctx = {0};
static inline void hash_data(const uint8_t *buf, size_t size) {
sha3_Update(&keccak_ctx, buf, size);
@ -56,7 +56,7 @@ static inline void hash_data(const uint8_t *buf, size_t size) {
* Push an RLP encoded length to the hash buffer.
*/
static void hash_rlp_length(uint32_t length, uint8_t firstbyte) {
uint8_t buf[4];
uint8_t buf[4] = {0};
if (length == 1 && firstbyte <= 0x7f) {
/* empty length header */
} else if (length <= 55) {
@ -84,7 +84,7 @@ static void hash_rlp_length(uint32_t length, uint8_t firstbyte) {
* Push an RLP encoded list length to the hash buffer.
*/
static void hash_rlp_list_length(uint32_t length) {
uint8_t buf[4];
uint8_t buf[4] = {0};
if (length <= 55) {
buf[0] = 0xc0 + length;
hash_data(buf, 1);
@ -122,7 +122,7 @@ static void hash_rlp_number(uint32_t number) {
if (!number) {
return;
}
uint8_t data[4];
uint8_t data[4] = {0};
data[0] = (number >> 24) & 0xff;
data[1] = (number >> 16) & 0xff;
data[2] = (number >> 8) & 0xff;
@ -182,8 +182,8 @@ static int ethereum_is_canonic(uint8_t v, uint8_t signature[64]) {
}
static void send_signature(void) {
uint8_t hash[32], sig[64];
uint8_t v;
uint8_t hash[32] = {0}, sig[64] = {0};
uint8_t v = 0;
layoutProgress(_("Signing"), 1000);
/* eip-155 replay protection */
@ -234,7 +234,7 @@ static void send_signature(void) {
*/
static void ethereumFormatAmount(const bignum256 *amnt, const TokenType *token,
char *buf, int buflen) {
bignum256 bn1e9;
bignum256 bn1e9 = {0};
bn_read_uint32(1000000000, &bn1e9);
const char *suffix = NULL;
int decimals = 18;
@ -260,13 +260,13 @@ static void ethereumFormatAmount(const bignum256 *amnt, const TokenType *token,
static void layoutEthereumConfirmTx(const uint8_t *to, uint32_t to_len,
const uint8_t *value, uint32_t value_len,
const TokenType *token) {
bignum256 val;
uint8_t pad_val[32];
bignum256 val = {0};
uint8_t pad_val[32] = {0};
memzero(pad_val, sizeof(pad_val));
memcpy(pad_val + (32 - value_len), value, value_len);
bn_read_be(pad_val, &val);
char amount[32];
char amount[32] = {0};
if (token == NULL) {
if (bn_is_zero(&val)) {
strcpy(amount, _("message"));
@ -282,7 +282,7 @@ static void layoutEthereumConfirmTx(const uint8_t *to, uint32_t to_len,
char _to3[] = "_______________?";
if (to_len) {
char to_str[41];
char to_str[41] = {0};
bool rskip60 = false;
// constants from trezor-common/defs/ethereum/networks.json
@ -311,8 +311,8 @@ static void layoutEthereumConfirmTx(const uint8_t *to, uint32_t to_len,
static void layoutEthereumData(const uint8_t *data, uint32_t len,
uint32_t total_len) {
char hexdata[3][17];
char summary[20];
char hexdata[3][17] = {0};
char summary[20] = {0};
uint32_t printed = 0;
for (int i = 0; i < 3; i++) {
uint32_t linelen = len - printed;
@ -343,10 +343,10 @@ static void layoutEthereumFee(const uint8_t *value, uint32_t value_len,
const uint8_t *gas_price, uint32_t gas_price_len,
const uint8_t *gas_limit, uint32_t gas_limit_len,
bool is_token) {
bignum256 val, gas;
uint8_t pad_val[32];
char tx_value[32];
char gas_value[32];
bignum256 val = {0}, gas = {0};
uint8_t pad_val[32] = {0};
char tx_value[32] = {0};
char gas_value[32] = {0};
memzero(tx_value, sizeof(tx_value));
memzero(gas_value, sizeof(gas_value));
@ -421,7 +421,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node) {
if (!msg->has_value) msg->value.size = 0;
if (!msg->has_data_initial_chunk) msg->data_initial_chunk.size = 0;
bool toset;
uint8_t pubkeyhash[20];
uint8_t pubkeyhash[20] = {0};
if (msg->has_to && ethereum_parse(msg->to, pubkeyhash)) {
toset = true;
} else {
@ -626,10 +626,10 @@ void ethereum_signing_abort(void) {
static void ethereum_message_hash(const uint8_t *message, size_t message_len,
uint8_t hash[32]) {
struct SHA3_CTX ctx;
struct SHA3_CTX ctx = {0};
sha3_256_Init(&ctx);
sha3_Update(&ctx, (const uint8_t *)"\x19" "Ethereum Signed Message:\n", 26);
uint8_t c;
uint8_t c = 0;
if (message_len >= 1000000000) {
c = '0' + message_len / 1000000000 % 10;
sha3_Update(&ctx, &c, 1);
@ -674,7 +674,7 @@ static void ethereum_message_hash(const uint8_t *message, size_t message_len,
void ethereum_message_sign(const EthereumSignMessage *msg, const HDNode *node,
EthereumMessageSignature *resp) {
uint8_t pubkeyhash[20];
uint8_t pubkeyhash[20] = {0};
if (!hdnode_get_ethereum_pubkeyhash(node, pubkeyhash)) {
return;
}
@ -685,10 +685,10 @@ void ethereum_message_sign(const EthereumSignMessage *msg, const HDNode *node,
ethereum_address_checksum(pubkeyhash, resp->address + 2, false, 0);
// ethereum_address_checksum adds trailing zero
uint8_t hash[32];
uint8_t hash[32] = {0};
ethereum_message_hash(msg->message.bytes, msg->message.size, hash);
uint8_t v;
uint8_t v = 0;
if (ecdsa_sign_digest(&secp256k1, node->private_key, hash,
resp->signature.bytes, &v, ethereum_is_canonic) != 0) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Signing failed"));
@ -707,14 +707,14 @@ int ethereum_message_verify(const EthereumVerifyMessage *msg) {
return 1;
}
uint8_t pubkeyhash[20];
uint8_t pubkeyhash[20] = {0};
if (!ethereum_parse(msg->address, pubkeyhash)) {
fsm_sendFailure(FailureType_Failure_DataError, _("Malformed address"));
return 1;
}
uint8_t pubkey[65];
uint8_t hash[32];
uint8_t pubkey[65] = {0};
uint8_t hash[32] = {0};
ethereum_message_hash(msg->message.bytes, msg->message.size, hash);
@ -730,7 +730,7 @@ int ethereum_message_verify(const EthereumVerifyMessage *msg) {
return 2;
}
struct SHA3_CTX ctx;
struct SHA3_CTX ctx = {0};
sha3_256_Init(&ctx);
sha3_Update(&ctx, pubkey + 1, 64);
keccak_Final(&ctx, hash);

@ -188,7 +188,7 @@ void fsm_sendFailure(FailureType code, const char *text)
}
static const CoinInfo *fsm_getCoin(bool has_name, const char *name) {
const CoinInfo *coin;
const CoinInfo *coin = NULL;
if (has_name) {
coin = coinByName(name);
} else {

@ -128,7 +128,7 @@ static const char *address_n_str(const uint32_t *address_n,
} else {
strlcat(path, " account #", sizeof(path));
}
char acc[3];
char acc[3] = {0};
memzero(acc, sizeof(acc));
if (accnum < 10) {
acc[0] = '0' + accnum;
@ -207,7 +207,7 @@ const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen) {
}
const char **split_message_hex(const uint8_t *msg, uint32_t len) {
char hex[32 * 2 + 1];
char hex[32 * 2 + 1] = {0};
memzero(hex, sizeof(hex));
uint32_t size = len;
if (len > 32) {
@ -262,9 +262,9 @@ void layoutHome(void) {
config_getLabel(label, sizeof(label));
}
uint8_t homescreen[HOMESCREEN_SIZE];
uint8_t homescreen[HOMESCREEN_SIZE] = {0};
if (config_getHomescreen(homescreen, sizeof(homescreen))) {
BITMAP b;
BITMAP b = {0};
b.width = 128;
b.height = 64;
b.data = homescreen;
@ -345,7 +345,7 @@ static void render_address_dialog(const CoinInfo *coin, const char *address,
}
void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out) {
char str_out[32 + 3];
char str_out[32 + 3] = {0};
bn_format_uint64(out->amount, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY,
0, false, str_out, sizeof(str_out) - 3);
strlcat(str_out, " to", sizeof(str_out));
@ -359,9 +359,9 @@ void layoutConfirmOutput(const CoinInfo *coin, const TxOutputType *out) {
}
void layoutConfirmOmni(const uint8_t *data, uint32_t size) {
const char *desc;
char str_out[32];
uint32_t tx_type, currency;
const char *desc = NULL;
char str_out[32] = {0};
uint32_t tx_type = 0, currency = 0;
REVERSE32(*(const uint32_t *)(data + 4), tx_type);
if (tx_type == 0x00000000 && size == 20) { // OMNI simple send
desc = _("Simple send of ");
@ -386,7 +386,7 @@ void layoutConfirmOmni(const uint8_t *data, uint32_t size) {
divisible = true;
break;
}
uint64_t amount_be, amount;
uint64_t amount_be = 0, amount = 0;
memcpy(&amount_be, data + 12, sizeof(uint64_t));
REVERSE64(amount_be, amount);
bn_format_uint64(amount, NULL, suffix, divisible ? BITCOIN_DIVISIBILITY : 0,
@ -410,7 +410,7 @@ static bool is_valid_ascii(const uint8_t *data, uint32_t size) {
}
void layoutConfirmOpReturn(const uint8_t *data, uint32_t size) {
const char **str;
const char **str = NULL;
if (!is_valid_ascii(data, size)) {
str = split_message_hex(data, size);
} else {
@ -423,7 +423,7 @@ void layoutConfirmOpReturn(const uint8_t *data, uint32_t size) {
void layoutConfirmTx(const CoinInfo *coin, uint64_t amount_out,
uint64_t amount_fee) {
char str_out[32], str_fee[32];
char str_out[32] = {0}, str_fee[32] = {0};
bn_format_uint64(amount_out, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY,
0, false, str_out, sizeof(str_out));
bn_format_uint64(amount_fee, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY,
@ -434,7 +434,7 @@ void layoutConfirmTx(const CoinInfo *coin, uint64_t amount_out,
}
void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee) {
char str_fee[32];
char str_fee[32] = {0};
bn_format_uint64(fee, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0,
false, str_fee, sizeof(str_fee));
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
@ -443,7 +443,7 @@ void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee) {
}
void layoutSignMessage(const uint8_t *msg, uint32_t len) {
const char **str;
const char **str = NULL;
if (!is_valid_ascii(msg, len)) {
str = split_message_hex(msg, len);
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
@ -458,7 +458,7 @@ void layoutSignMessage(const uint8_t *msg, uint32_t len) {
}
void layoutVerifyMessage(const uint8_t *msg, uint32_t len) {
const char **str;
const char **str = NULL;
if (!is_valid_ascii(msg, len)) {
str = split_message_hex(msg, len);
layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
@ -506,7 +506,7 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) {
layoutLast = layoutResetWord;
layoutSwipe();
const char *btnYes;
const char *btnYes = NULL;
if (last) {
if (pass == 1) {
btnYes = _("Finish");
@ -517,7 +517,7 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) {
btnYes = _("Next");
}
const char *action;
const char *action = NULL;
if (pass == 1) {
action = _("Please check the seed");
} else {
@ -581,8 +581,8 @@ void layoutAddress(const char *address, const char *desc, bool qrcode,
: address[i];
}
}
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
int side = 0;
if (qrcodegen_encodeText(ignorecase ? address_upcase : address, tempdata,
@ -641,7 +641,7 @@ void layoutAddress(const char *address, const char *desc, bool qrcode,
}
void layoutPublicKey(const uint8_t *pubkey) {
char desc[16];
char desc[16] = {0};
strlcpy(desc, "Public Key: 00", sizeof(desc));
if (pubkey[0] == 1) {
/* ed25519 public key */
@ -655,9 +655,9 @@ void layoutPublicKey(const uint8_t *pubkey) {
}
void layoutSignIdentity(const IdentityType *identity, const char *challenge) {
char row_proto[8 + 11 + 1];
char row_hostport[64 + 6 + 1];
char row_user[64 + 8 + 1];
char row_proto[8 + 11 + 1] = {0};
char row_hostport[64 + 6 + 1] = {0};
char row_user[64 + 8 + 1] = {0};
bool is_gpg = (strcmp(identity->proto, "gpg") == 0);
@ -719,9 +719,9 @@ void layoutSignIdentity(const IdentityType *identity, const char *challenge) {
}
void layoutDecryptIdentity(const IdentityType *identity) {
char row_proto[8 + 11 + 1];
char row_hostport[64 + 6 + 1];
char row_user[64 + 8 + 1];
char row_proto[8 + 11 + 1] = {0};
char row_hostport[64 + 6 + 1] = {0};
char row_user[64 + 8 + 1] = {0};
if (identity->has_proto && identity->proto[0]) {
strlcpy(row_proto, identity->proto, sizeof(row_proto));
@ -786,7 +786,7 @@ void layoutNEMDialog(const BITMAP *icon, const char *btnNo, const char *btnYes,
void layoutNEMTransferXEM(const char *desc, uint64_t quantity,
const bignum256 *multiplier, uint64_t fee) {
char str_out[32], str_fee[32];
char str_out[32] = {0}, str_fee[32] = {0};
nem_mosaicFormatAmount(NEM_MOSAIC_DEFINITION_XEM, quantity, multiplier,
str_out, sizeof(str_out));
@ -800,7 +800,7 @@ void layoutNEMTransferXEM(const char *desc, uint64_t quantity,
void layoutNEMNetworkFee(const char *desc, bool confirm, const char *fee1_desc,
uint64_t fee1, const char *fee2_desc, uint64_t fee2) {
char str_fee1[32], str_fee2[32];
char str_fee1[32] = {0}, str_fee2[32] = {0};
nem_mosaicFormatAmount(NEM_MOSAIC_DEFINITION_XEM, fee1, NULL, str_fee1,
sizeof(str_fee1));
@ -818,7 +818,7 @@ void layoutNEMNetworkFee(const char *desc, bool confirm, const char *fee1_desc,
void layoutNEMTransferMosaic(const NEMMosaicDefinition *definition,
uint64_t quantity, const bignum256 *multiplier,
uint8_t network) {
char str_out[32], str_levy[32];
char str_out[32] = {0}, str_levy[32] = {0};
nem_mosaicFormatAmount(definition, quantity, multiplier, str_out,
sizeof(str_out));
@ -838,10 +838,10 @@ void layoutNEMTransferMosaic(const NEMMosaicDefinition *definition,
void layoutNEMTransferUnknownMosaic(const char *namespace, const char *mosaic,
uint64_t quantity,
const bignum256 *multiplier) {
char mosaic_name[32];
char mosaic_name[32] = {0};
nem_mosaicFormatName(namespace, mosaic, mosaic_name, sizeof(mosaic_name));
char str_out[32];
char str_out[32] = {0};
nem_mosaicFormatAmount(NULL, quantity, multiplier, str_out, sizeof(str_out));
char *decimal = strchr(str_out, '.');
@ -858,6 +858,8 @@ void layoutNEMTransferPayload(const uint8_t *payload, size_t length,
bool encrypted) {
if (length >= 1 && payload[0] == 0xFE) {
char encoded[(length - 1) * 2 + 1];
memset(encoded, 0, sizeof(encoded));
data2hex(&payload[1], length - 1, encoded);
const char **str =
@ -884,7 +886,7 @@ void layoutNEMMosaicDescription(const char *description) {
}
void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
const NEMMosaicDefinition *mosaic;
const NEMMosaicDefinition *mosaic = NULL;
if (nem_mosaicMatches(definition, definition->levy_namespace,
definition->levy_mosaic, network)) {
mosaic = definition;
@ -893,13 +895,13 @@ void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
definition->levy_mosaic, network);
}
char mosaic_name[32];
char mosaic_name[32] = {0};
if (mosaic == NULL) {
nem_mosaicFormatName(definition->levy_namespace, definition->levy_mosaic,
mosaic_name, sizeof(mosaic_name));
}
char str_out[32];
char str_out[32] = {0};
switch (definition->levy) {
case NEMMosaicLevy_MosaicLevy_Percentile:
@ -939,7 +941,7 @@ static inline bool is_slip18(const uint32_t *address_n,
void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count,
const uint8_t *data, uint32_t len, bool final_sign) {
char *desc = final_sign ? _("CoSi sign message?") : _("CoSi commit message?");
char desc_buf[32];
char desc_buf[32] = {0};
if (is_slip18(address_n, address_n_count)) {
if (final_sign) {
strlcpy(desc_buf, _("CoSi sign index #?"), sizeof(desc_buf));
@ -950,7 +952,7 @@ void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count,
}
desc = desc_buf;
}
char str[4][17];
char str[4][17] = {0};
if (len == 32) {
data2hex(data, 8, str[0]);
data2hex(data + 8, 8, str[1]);

@ -30,7 +30,7 @@
void lisk_get_address_from_public_key(const uint8_t *public_key,
char *address) {
uint64_t digest[4];
uint64_t digest[4] = {0};
sha256_Raw(public_key, 32, (uint8_t *)digest);
bn_format_uint64(digest[0], NULL, "L", 0, 0, false, address,
MAX_LISK_ADDRESS_SIZE);
@ -38,10 +38,10 @@ void lisk_get_address_from_public_key(const uint8_t *public_key,
void lisk_message_hash(const uint8_t *message, size_t message_len,
uint8_t hash[32]) {
SHA256_CTX ctx;
SHA256_CTX ctx = {0};
sha256_Init(&ctx);
sha256_Update(&ctx, (const uint8_t *)"\x15" "Lisk Signed Message:\n", 22);
uint8_t varint[5];
uint8_t varint[5] = {0};
uint32_t l = ser_length(message_len, varint);
sha256_Update(&ctx, varint, l);
sha256_Update(&ctx, message, message_len);
@ -60,8 +60,8 @@ void lisk_sign_message(const HDNode *node, const LiskSignMessage *msg,
layoutProgressSwipe(_("Signing"), 0);
uint8_t signature[64];
uint8_t hash[32];
uint8_t signature[64] = {0};
uint8_t hash[32] = {0};
lisk_message_hash(msg->message.bytes, msg->message.size, hash);
ed25519_sign(hash, 32, node->private_key, &node->public_key[1], signature);
@ -76,7 +76,7 @@ void lisk_sign_message(const HDNode *node, const LiskSignMessage *msg,
}
bool lisk_verify_message(const LiskVerifyMessage *msg) {
uint8_t hash[32];
uint8_t hash[32] = {0};
lisk_message_hash(msg->message.bytes, msg->message.size, hash);
return 0 == ed25519_sign_open(hash, 32, msg->public_key.bytes,
msg->signature.bytes);
@ -98,7 +98,7 @@ static void lisk_update_raw_tx(const HDNode *node, LiskSignTx *msg) {
}
static void lisk_hashupdate_uint32(SHA256_CTX *ctx, uint32_t value) {
uint8_t data[4];
uint8_t data[4] = {0};
write_le(data, value);
sha256_Update(ctx, data, sizeof(data));
}
@ -108,7 +108,7 @@ static void lisk_hashupdate_uint64_le(SHA256_CTX *ctx, uint64_t value) {
}
static void lisk_hashupdate_uint64_be(SHA256_CTX *ctx, uint64_t value) {
uint8_t data[8];
uint8_t data[8] = {0};
data[0] = value >> 56;
data[1] = value >> 48;
data[2] = value >> 40;
@ -174,7 +174,7 @@ void lisk_sign_tx(const HDNode *node, LiskSignTx *msg, LiskSignedTx *resp) {
lisk_update_raw_tx(node, msg);
if (msg->has_transaction) {
SHA256_CTX ctx;
SHA256_CTX ctx = {0};
sha256_Init(&ctx);
switch (msg->transaction.type) {
@ -256,7 +256,7 @@ void lisk_sign_tx(const HDNode *node, LiskSignTx *msg, LiskSignedTx *resp) {
msg->transaction.signature.size);
}
uint8_t hash[32];
uint8_t hash[32] = {0};
sha256_Final(&ctx, hash);
ed25519_sign(hash, 32, node->private_key, &node->public_key[1],
resp->signature.bytes);
@ -282,7 +282,7 @@ void layoutLiskVerifyAddress(const char *address) {
}
void layoutRequireConfirmTx(char *recipient_id, uint64_t amount) {
char formated_amount[MAX_LISK_VALUE_SIZE];
char formated_amount[MAX_LISK_VALUE_SIZE] = {0};
const char **str =
split_message((const uint8_t *)recipient_id, strlen(recipient_id), 16);
lisk_format_value(amount, formated_amount);
@ -292,8 +292,8 @@ void layoutRequireConfirmTx(char *recipient_id, uint64_t amount) {
}
void layoutRequireConfirmFee(uint64_t fee, uint64_t amount) {
char formated_amount[MAX_LISK_VALUE_SIZE];
char formated_fee[MAX_LISK_VALUE_SIZE];
char formated_amount[MAX_LISK_VALUE_SIZE] = {0};
char formated_fee[MAX_LISK_VALUE_SIZE] = {0};
lisk_format_value(amount, formated_amount);
lisk_format_value(fee, formated_fee);
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
@ -314,8 +314,8 @@ void layoutRequireConfirmDelegateRegistration(LiskTransactionAsset *asset) {
void layoutRequireConfirmCastVotes(LiskTransactionAsset *asset) {
uint8_t plus = 0;
uint8_t minus = 0;
char add_votes_txt[13];
char remove_votes_txt[16];
char add_votes_txt[13] = {0};
char remove_votes_txt[16] = {0};
for (int i = 0; i < asset->votes_count; i++) {
if (asset->votes[i][0] == '+') {
@ -336,9 +336,9 @@ void layoutRequireConfirmCastVotes(LiskTransactionAsset *asset) {
}
void layoutRequireConfirmMultisig(LiskTransactionAsset *asset) {
char keys_group_str[25];
char life_time_str[14];
char min_str[8];
char keys_group_str[25] = {0};
char life_time_str[14] = {0};
char min_str[8] = {0};
bn_format_uint64(asset->multisignature.keys_group_count,
"Keys group length: ", NULL, 0, 0, false, keys_group_str,

@ -164,12 +164,12 @@ bool msg_write_common(char type, uint16_t msg_id, const void *msg_ptr) {
return false;
}
size_t len;
size_t len = 0;
if (!pb_get_encoded_size(&len, fields, msg_ptr)) {
return false;
}
void (*append)(uint8_t);
void (*append)(uint8_t) = NULL;
bool (*pb_callback)(pb_ostream_t *, const uint8_t *, size_t);
if (type == 'n') {

@ -224,7 +224,7 @@ bool nem_askTransfer(const NEMTransactionCommon *common,
}
}
bignum256 multiplier;
bignum256 multiplier = {0};
bn_read_uint64(transfer->amount, &multiplier);
if (unknownMosaic) {
@ -399,7 +399,7 @@ bool nem_askMosaicCreation(const NEMTransactionCommon *common,
return false;
}
char str_out[32];
char str_out[32] = {0};
bn_format_uint64(mosaic_creation->definition.supply, NULL, NULL,
mosaic_creation->definition.divisibility,
@ -478,7 +478,7 @@ bool nem_askSupplyChange(const NEMTransactionCommon *common,
return false;
}
char str_out[32];
char str_out[32] = {0};
bn_format_uint64(supply_change->delta, NULL, NULL, 0, 0, false, str_out,
sizeof(str_out));
@ -523,7 +523,7 @@ bool nem_askAggregateModification(
}
}
char address[NEM_ADDRESS_SIZE + 1];
char address[NEM_ADDRESS_SIZE + 1] = {0};
for (size_t i = 0; i < aggregate_modification->modifications_count; i++) {
const NEMCosignatoryModification *modification =
@ -543,7 +543,7 @@ bool nem_askAggregateModification(
int32_t relative_change = aggregate_modification->relative_change;
if (relative_change) {
char str_out[32];
char str_out[32] = {0};
bn_format_uint64(relative_change < 0 ? -relative_change : relative_change,
NULL, NULL, 0, 0, false, str_out, sizeof(str_out));
@ -685,7 +685,7 @@ static inline size_t format_amount(const NEMMosaicDefinition *definition,
const bignum256 *amnt,
const bignum256 *multiplier, int divisor,
char *str_out, size_t size) {
bignum256 val;
bignum256 val = {0};
memcpy(&val, amnt, sizeof(bignum256));
if (multiplier) {
@ -746,7 +746,7 @@ void nem_canonicalizeMosaics(NEMTransfer *transfer) {
NEMMosaic *b = &mosaics[j];
if (nem_mosaicCompare(a, b) > 0) {
NEMMosaic temp;
NEMMosaic temp = {0};
memcpy(&temp, a, sizeof(NEMMosaic));
memcpy(a, b, sizeof(NEMMosaic));
memcpy(b, &temp, sizeof(NEMMosaic));
@ -758,7 +758,7 @@ void nem_canonicalizeMosaics(NEMTransfer *transfer) {
void nem_mosaicFormatAmount(const NEMMosaicDefinition *definition,
uint64_t quantity, const bignum256 *multiplier,
char *str_out, size_t size) {
bignum256 amnt;
bignum256 amnt = {0};
bn_read_uint64(quantity, &amnt);
format_amount(definition, &amnt, multiplier, 0, str_out, size);
@ -771,7 +771,7 @@ bool nem_mosaicFormatLevy(const NEMMosaicDefinition *definition,
return false;
}
bignum256 amnt, fee;
bignum256 amnt = {0}, fee = {0};
bn_read_uint64(quantity, &amnt);
bn_read_uint64(definition->fee, &fee);

@ -73,7 +73,7 @@ static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = {
static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count)
{
size_t i;
size_t i = 0;
pb_byte_t *dest = (pb_byte_t*)stream->state;
stream->state = dest + count;
@ -128,9 +128,9 @@ bool checkreturn pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t cou
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field,
const void *pData, size_t count, pb_encoder_t func)
{
size_t i;
const void *p;
size_t size;
size_t i = 0;
const void *p = NULL;
size_t size = 0;
if (count == 0)
return true;
@ -688,7 +688,7 @@ bool checkreturn pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fie
{
/* First calculate the message size using a non-writing substream. */
pb_ostream_t substream = PB_OSTREAM_SIZING;
size_t size;
size_t size = 0;
bool status;
if (!pb_encode(&substream, fields, src_struct))

@ -64,7 +64,7 @@ void pinmatrix_start(const char *text) {
}
void pinmatrix_done(char *pin) {
int k, i = 0;
int i = 0, k = 0;
while (pin && pin[i]) {
k = pin[i] - '1';
if (k >= 0 && k <= 8) {

@ -39,7 +39,7 @@ bool protectAbortedByCancel = false;
bool protectAbortedByInitialize = false;
bool protectButton(ButtonRequestType type, bool confirm_only) {
ButtonRequest resp;
ButtonRequest resp = {0};
bool result = false;
bool acked = false;
#if DEBUG_LINK
@ -112,7 +112,7 @@ bool protectButton(ButtonRequestType type, bool confirm_only) {
}
const char *requestPin(PinMatrixRequestType type, const char *text) {
PinMatrixRequest resp;
PinMatrixRequest resp = {0};
memzero(&resp, sizeof(PinMatrixRequest));
resp.has_type = true;
resp.type = type;
@ -283,7 +283,7 @@ bool protectPassphrase(void) {
return true;
}
PassphraseRequest resp;
PassphraseRequest resp = {0};
memzero(&resp, sizeof(PassphraseRequest));
usbTiny(1);
msg_write(MessageType_MessageType_PassphraseRequest, &resp);

@ -143,7 +143,7 @@ static void format_number(char *dest, int number) {
/* Send a request for a new word/matrix code to the PC.
*/
static void recovery_request(void) {
WordRequest resp;
WordRequest resp = {0};
memzero(&resp, sizeof(WordRequest));
resp.has_type = true;
resp.type = awaiting_word == 1
@ -323,8 +323,8 @@ static void display_choices(bool twoColumn, char choices[9][12], int num) {
* Generates a new matrix and requests the next pin.
*/
static void next_matrix(void) {
char word_choices[9][12];
uint32_t idx, num;
char word_choices[9][12] = {0};
uint32_t idx = 0, num = 0;
bool last = (word_index % 4) == 3;
/* Build the matrix:

@ -68,7 +68,7 @@ void reset_init(bool display_random, uint32_t _strength,
if (display_random) {
for (int start = 0; start < 2; start++) {
char ent_str[4][17];
char ent_str[4][17] = {0};
char desc[] = "Internal entropy _/2:";
data2hex(int_entropy + start * 16, 4, ent_str[0]);
data2hex(int_entropy + start * 16 + 4, 4, ent_str[1]);
@ -109,7 +109,7 @@ void reset_init(bool display_random, uint32_t _strength,
config_setLabel(label);
config_setU2FCounter(u2f_counter);
EntropyRequest resp;
EntropyRequest resp = {0};
memzero(&resp, sizeof(EntropyRequest));
msg_write(MessageType_MessageType_EntropyRequest, &resp);
awaiting_entropy = true;
@ -123,7 +123,7 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len) {
}
awaiting_entropy = false;
SHA256_CTX ctx;
SHA256_CTX ctx = {0};
sha256_Init(&ctx);
sha256_Update(&ctx, int_entropy, 32);
sha256_Update(&ctx, ext_entropy, len);

@ -417,7 +417,7 @@ bool check_change_bip32_path(const TxOutputType *toutput) {
bool compile_input_script_sig(TxInputType *tinput) {
if (!multisig_fp_mismatch) {
// check that this is still multisig
uint8_t h[32];
uint8_t h[32] = {0};
if (!tinput->has_multisig ||
cryptoMultisigFingerprint(&(tinput->multisig), h) == 0 ||
memcmp(multisig_fp, h, 32) != 0) {
@ -445,7 +445,7 @@ bool compile_input_script_sig(TxInputType *tinput) {
tinput->script_sig.size = compile_script_multisig(coin, &(tinput->multisig),
tinput->script_sig.bytes);
} else { // SPENDADDRESS
uint8_t hash[20];
uint8_t hash[20] = {0};
ecdsa_get_pubkeyhash(node.public_key, coin->curve->hasher_pubkey, hash);
tinput->script_sig.size =
compile_script_sig(coin->address_type, hash, tinput->script_sig.bytes);
@ -557,7 +557,7 @@ static bool signing_check_input(const TxInputType *txinput) {
/* (if all input share the same fingerprint, outputs having the same
* fingerprint will be considered as change outputs) */
if (txinput->has_multisig && !multisig_fp_mismatch) {
uint8_t h[32];
uint8_t h[32] = {0};
if (cryptoMultisigFingerprint(&txinput->multisig, h) == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("Error computing multisig fingerprint"));
@ -610,7 +610,7 @@ static bool signing_check_input(const TxInputType *txinput) {
// check if the hash of the prevtx matches
static bool signing_check_prevtx_hash(void) {
uint8_t hash[32];
uint8_t hash[32] = {0};
tx_hash_final(&tp, hash, true);
if (memcmp(hash, input.prev_hash.bytes, 32) != 0) {
fsm_sendFailure(FailureType_Failure_DataError,
@ -640,7 +640,7 @@ static bool signing_check_output(TxOutputType *txoutput) {
* For multisig check that all inputs are multisig
*/
if (txoutput->has_multisig) {
uint8_t h[32];
uint8_t h[32] = {0};
if (multisig_fp_set && !multisig_fp_mismatch &&
cryptoMultisigFingerprint(&(txoutput->multisig), h) &&
memcmp(multisig_fp, h, 32) == 0) {
@ -720,7 +720,7 @@ static bool signing_check_fee(void) {
return false;
}
}
uint64_t fee;
uint64_t fee = 0;
if (spending <= to_spend) {
fee = to_spend - spending;
if (fee > ((uint64_t)tx_weight * coin->maxfee_kb) / 4000) {
@ -788,7 +788,7 @@ static void phase1_request_next_output(void) {
static void signing_hash_bip143(const TxInputType *txinput, uint8_t *hash) {
uint32_t hash_type = signing_hash_type();
Hasher hasher_preimage;
Hasher hasher_preimage = {0};
hasher_Init(&hasher_preimage, coin->curve->hasher_sign);
hasher_Update(&hasher_preimage, (const uint8_t *)&version, 4); // nVersion
hasher_Update(&hasher_preimage, hash_prevouts, 32); // hashPrevouts
@ -809,10 +809,10 @@ static void signing_hash_bip143(const TxInputType *txinput, uint8_t *hash) {
static void signing_hash_zip143(const TxInputType *txinput, uint8_t *hash) {
uint32_t hash_type = signing_hash_type();
uint8_t personal[16];
uint8_t personal[16] = {0};
memcpy(personal, "ZcashSigHash", 12);
memcpy(personal + 12, &branch_id, 4);
Hasher hasher_preimage;
Hasher hasher_preimage = {0};
hasher_InitParam(&hasher_preimage, HASHER_BLAKE2B_PERSONAL, personal,
sizeof(personal));
uint32_t ver = version | TX_OVERWINTERED; // 1. nVersion | fOverwintered
@ -843,10 +843,10 @@ static void signing_hash_zip143(const TxInputType *txinput, uint8_t *hash) {
static void signing_hash_zip243(const TxInputType *txinput, uint8_t *hash) {
uint32_t hash_type = signing_hash_type();
uint8_t personal[16];
uint8_t personal[16] = {0};
memcpy(personal, "ZcashSigHash", 12);
memcpy(personal + 12, &branch_id, 4);
Hasher hasher_preimage;
Hasher hasher_preimage = {0};
hasher_InitParam(&hasher_preimage, HASHER_BLAKE2B_PERSONAL, personal,
sizeof(personal));
uint32_t ver = version | TX_OVERWINTERED; // 1. nVersion | fOverwintered
@ -884,7 +884,7 @@ static void signing_hash_zip243(const TxInputType *txinput, uint8_t *hash) {
static void signing_hash_decred(const uint8_t *hash_witness, uint8_t *hash) {
uint32_t hash_type = signing_hash_type();
Hasher hasher_preimage;
Hasher hasher_preimage = {0};
hasher_Init(&hasher_preimage, coin->curve->hasher_sign);
hasher_Update(&hasher_preimage, (const uint8_t *)&hash_type, 4);
hasher_Update(&hasher_preimage, decred_hash_prefix, 32);
@ -941,7 +941,7 @@ static bool signing_sign_hash(TxInputType *txinput, const uint8_t *private_key,
}
static bool signing_sign_input(void) {
uint8_t hash[32];
uint8_t hash[32] = {0};
hasher_Final(&hasher_check, hash);
if (memcmp(hash, hash_outputs, 32) != 0) {
fsm_sendFailure(FailureType_Failure_DataError,
@ -962,7 +962,7 @@ static bool signing_sign_input(void) {
static bool signing_sign_segwit_input(TxInputType *txinput) {
// idx1: index to sign
uint8_t hash[32];
uint8_t hash[32] = {0};
if (txinput->script_type == InputScriptType_SPENDWITNESS ||
txinput->script_type == InputScriptType_SPENDP2SHWITNESS) {
@ -1042,7 +1042,7 @@ static bool signing_sign_segwit_input(TxInputType *txinput) {
#if !BITCOIN_ONLY
static bool signing_sign_decred_input(TxInputType *txinput) {
uint8_t hash[32], hash_witness[32];
uint8_t hash[32] = {}, hash_witness[32] = {};
tx_hash_final(&ti, hash_witness, false);
signing_hash_decred(hash_witness, hash);
resp.has_serialized = true;
@ -1325,7 +1325,7 @@ void signing_txack(TransactionType *tx) {
idx2++;
send_req_4_input();
} else {
uint8_t hash[32];
uint8_t hash[32] = {0};
hasher_Final(&hasher_check, hash);
if (memcmp(hash, hash_check, 32) != 0) {
fsm_sendFailure(FailureType_Failure_DataError,
@ -1405,7 +1405,7 @@ void signing_txack(TransactionType *tx) {
}
authorized_amount -= tx->inputs[0].amount;
uint8_t hash[32];
uint8_t hash[32] = {0};
#if !BITCOIN_ONLY
if (overwintered) {
switch (version) {
@ -1550,7 +1550,7 @@ void signing_txack(TransactionType *tx) {
}
for (idx2 = 0; idx2 < inputs_count; idx2++) {
uint32_t r;
uint32_t r = 0;
if (idx2 == idx1) {
r = tx_serialize_decred_witness_hash(&ti, &tx->inputs[0]);
} else {

@ -62,7 +62,7 @@ bool stellar_signingInit(const StellarSignTx *msg) {
// Calculate sha256 for network passphrase
// max length defined in messages.options
uint8_t network_hash[32];
uint8_t network_hash[32] = {0};
sha256_Raw((uint8_t *)msg->network_passphrase,
strnlen(msg->network_passphrase, 1024), network_hash);
@ -171,7 +171,7 @@ bool stellar_confirmSourceAccount(bool has_source_account,
}
// Convert account string to public key bytes
uint8_t bytes[32];
uint8_t bytes[32] = {0};
if (!stellar_getAddressBytes(str_account, bytes)) {
return false;
}
@ -205,7 +205,7 @@ bool stellar_confirmCreateAccountOp(const StellarCreateAccountOp *msg) {
stellar_hashupdate_uint32(0);
// Validate new account and convert to bytes
uint8_t new_account_bytes[STELLAR_KEY_SIZE];
uint8_t new_account_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->new_account, new_account_bytes)) {
stellar_signingAbort(_("Invalid new account address"));
return false;
@ -214,8 +214,8 @@ bool stellar_confirmCreateAccountOp(const StellarCreateAccountOp *msg) {
const char **str_addr_rows = stellar_lineBreakAddress(new_account_bytes);
// Amount being funded
char str_amount_line[32];
char str_amount[32];
char str_amount_line[32] = {0};
char str_amount[32] = {0};
stellar_format_stroops(msg->starting_balance, str_amount, sizeof(str_amount));
strlcpy(str_amount_line, _("With "), sizeof(str_amount_line));
@ -252,7 +252,7 @@ bool stellar_confirmPaymentOp(const StellarPaymentOp *msg) {
stellar_hashupdate_uint32(1);
// Validate destination account and convert to bytes
uint8_t destination_account_bytes[STELLAR_KEY_SIZE];
uint8_t destination_account_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->destination_account,
destination_account_bytes)) {
stellar_signingAbort(_("Invalid destination account"));
@ -263,16 +263,16 @@ bool stellar_confirmPaymentOp(const StellarPaymentOp *msg) {
stellar_lineBreakAddress(destination_account_bytes);
// To: G...
char str_to[32];
char str_to[32] = {0};
strlcpy(str_to, _("To: "), sizeof(str_to));
strlcat(str_to, str_addr_rows[0], sizeof(str_to));
char str_asset_row[32];
char str_asset_row[32] = {0};
memzero(str_asset_row, sizeof(str_asset_row));
stellar_format_asset(&(msg->asset), str_asset_row, sizeof(str_asset_row));
char str_pay_amount[32];
char str_amount[32];
char str_pay_amount[32] = {0};
char str_amount[32] = {0};
stellar_format_stroops(msg->amount, str_amount, sizeof(str_amount));
strlcpy(str_pay_amount, _("Pay "), sizeof(str_pay_amount));
@ -310,7 +310,7 @@ bool stellar_confirmPathPaymentOp(const StellarPathPaymentOp *msg) {
stellar_hashupdate_uint32(2);
// Validate destination account and convert to bytes
uint8_t destination_account_bytes[STELLAR_KEY_SIZE];
uint8_t destination_account_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->destination_account,
destination_account_bytes)) {
stellar_signingAbort(_("Invalid destination account"));
@ -320,19 +320,19 @@ bool stellar_confirmPathPaymentOp(const StellarPathPaymentOp *msg) {
stellar_lineBreakAddress(destination_account_bytes);
// To: G...
char str_to[32];
char str_to[32] = {0};
strlcpy(str_to, _("To: "), sizeof(str_to));
strlcat(str_to, str_dest_rows[0], sizeof(str_to));
char str_send_asset[32];
char str_dest_asset[32];
char str_send_asset[32] = {0};
char str_dest_asset[32] = {0};
stellar_format_asset(&(msg->send_asset), str_send_asset,
sizeof(str_send_asset));
stellar_format_asset(&(msg->destination_asset), str_dest_asset,
sizeof(str_dest_asset));
char str_pay_amount[32];
char str_amount[32];
char str_pay_amount[32] = {0};
char str_amount[32] = {0};
stellar_format_stroops(msg->destination_amount, str_amount,
sizeof(str_amount));
@ -355,8 +355,8 @@ bool stellar_confirmPathPaymentOp(const StellarPathPaymentOp *msg) {
}
// Confirm what the sender is using to pay
char str_source_amount[32];
char str_source_number[32];
char str_source_amount[32] = {0};
char str_source_number[32] = {0};
stellar_format_stroops(msg->send_max, str_source_number,
sizeof(str_source_number));
@ -408,11 +408,11 @@ bool stellar_confirmManageOfferOp(const StellarManageOfferOp *msg) {
stellar_hashupdate_uint32(3);
// New Offer / Delete #123 / Update #123
char str_offer[32];
char str_offer[32] = {0};
if (msg->offer_id == 0) {
strlcpy(str_offer, _("New Offer"), sizeof(str_offer));
} else {
char str_offer_id[20];
char str_offer_id[20] = {0};
stellar_format_uint64(msg->offer_id, str_offer_id, sizeof(str_offer_id));
if (msg->amount == 0) {
@ -424,9 +424,9 @@ bool stellar_confirmManageOfferOp(const StellarManageOfferOp *msg) {
strlcat(str_offer, str_offer_id, sizeof(str_offer));
}
char str_selling[32];
char str_sell_amount[32];
char str_selling_asset[32];
char str_selling[32] = {0};
char str_sell_amount[32] = {0};
char str_selling_asset[32] = {0};
stellar_format_asset(&(msg->selling_asset), str_selling_asset,
sizeof(str_selling_asset));
@ -439,9 +439,9 @@ bool stellar_confirmManageOfferOp(const StellarManageOfferOp *msg) {
strlcpy(str_selling, _("Sell "), sizeof(str_selling));
strlcat(str_selling, str_sell_amount, sizeof(str_selling));
char str_buying[32];
char str_buying_asset[32];
char str_price[32];
char str_buying[32] = {0};
char str_buying_asset[32] = {0};
char str_price[32] = {0};
stellar_format_asset(&(msg->buying_asset), str_buying_asset,
sizeof(str_buying_asset));
@ -495,16 +495,16 @@ bool stellar_confirmCreatePassiveOfferOp(
stellar_hashupdate_uint32(4);
// New Offer / Delete #123 / Update #123
char str_offer[32];
char str_offer[32] = {0};
if (msg->amount == 0) {
strlcpy(str_offer, _("Delete Passive Offer"), sizeof(str_offer));
} else {
strlcpy(str_offer, _("New Passive Offer"), sizeof(str_offer));
}
char str_selling[32];
char str_sell_amount[32];
char str_selling_asset[32];
char str_selling[32] = {0};
char str_sell_amount[32] = {0};
char str_selling_asset[32] = {0};
stellar_format_asset(&(msg->selling_asset), str_selling_asset,
sizeof(str_selling_asset));
@ -517,9 +517,9 @@ bool stellar_confirmCreatePassiveOfferOp(
strlcpy(str_selling, _("Sell "), sizeof(str_selling));
strlcat(str_selling, str_sell_amount, sizeof(str_selling));
char str_buying[32];
char str_buying_asset[32];
char str_price[32];
char str_buying[32] = {0};
char str_buying_asset[32] = {0};
char str_price[32] = {0};
stellar_format_asset(&(msg->buying_asset), str_buying_asset,
sizeof(str_buying_asset));
@ -570,8 +570,8 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
stellar_hashupdate_uint32(5);
// Something like Set Inflation Destination
char str_title[32];
char rows[4][32];
char str_title[32] = {0};
char rows[4][32] = {0};
int row_idx = 0;
memzero(rows, sizeof(rows));
@ -581,7 +581,7 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
strlcpy(str_title, _("Set Inflation Destination"), sizeof(str_title));
// Validate account and convert to bytes
uint8_t inflation_destination_account_bytes[STELLAR_KEY_SIZE];
uint8_t inflation_destination_account_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->inflation_destination_account,
inflation_destination_account_bytes)) {
stellar_signingAbort(_("Invalid inflation destination account"));
@ -682,7 +682,7 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
row_idx = 0;
stellar_hashupdate_bool(msg->has_master_weight);
if (msg->has_master_weight) {
char str_master_weight[10 + 1];
char str_master_weight[10 + 1] = {0};
show_thresholds_confirm = true;
stellar_format_uint32(msg->master_weight, str_master_weight,
sizeof(str_master_weight));
@ -696,7 +696,7 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
stellar_hashupdate_bool(msg->has_low_threshold);
if (msg->has_low_threshold) {
char str_low_threshold[10 + 1];
char str_low_threshold[10 + 1] = {0};
show_thresholds_confirm = true;
stellar_format_uint32(msg->low_threshold, str_low_threshold,
sizeof(str_low_threshold));
@ -709,7 +709,7 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
}
stellar_hashupdate_bool(msg->has_medium_threshold);
if (msg->has_medium_threshold) {
char str_med_threshold[10 + 1];
char str_med_threshold[10 + 1] = {0};
show_thresholds_confirm = true;
stellar_format_uint32(msg->medium_threshold, str_med_threshold,
sizeof(str_med_threshold));
@ -722,7 +722,7 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
}
stellar_hashupdate_bool(msg->has_high_threshold);
if (msg->has_high_threshold) {
char str_high_threshold[10 + 1];
char str_high_threshold[10 + 1] = {0};
show_thresholds_confirm = true;
stellar_format_uint32(msg->high_threshold, str_high_threshold,
sizeof(str_high_threshold));
@ -782,14 +782,14 @@ bool stellar_confirmSetOptionsOp(const StellarSetOptionsOp *msg) {
}
// Format weight as a string
char str_weight[16];
char str_weight[16] = {0};
stellar_format_uint32(msg->signer_weight, str_weight, sizeof(str_weight));
char str_weight_row[32];
char str_weight_row[32] = {0};
strlcpy(str_weight_row, _("Weight: "), sizeof(str_weight_row));
strlcat(str_weight_row, str_weight, sizeof(str_weight_row));
// 0 = account, 1 = pre-auth, 2 = hash(x)
char str_signer_type[16];
char str_signer_type[16] = {0};
bool needs_hash_confirm = false;
if (msg->signer_type == 0) {
strlcpy(str_signer_type, _("account"), sizeof(str_signer_type));
@ -873,7 +873,7 @@ bool stellar_confirmChangeTrustOp(const StellarChangeTrustOp *msg) {
stellar_hashupdate_uint32(6);
// Add Trust: USD
char str_title[32];
char str_title[32] = {0};
if (msg->limit == 0) {
strlcpy(str_title, _("DELETE Trust: "), sizeof(str_title));
} else {
@ -882,19 +882,19 @@ bool stellar_confirmChangeTrustOp(const StellarChangeTrustOp *msg) {
strlcat(str_title, msg->asset.code, sizeof(str_title));
// Amount: MAX (or a number)
char str_amount_row[32];
char str_amount_row[32] = {0};
strlcpy(str_amount_row, _("Amount: "), sizeof(str_amount_row));
if (msg->limit == 9223372036854775807) {
strlcat(str_amount_row, _("[Maximum]"), sizeof(str_amount_row));
} else {
char str_amount[32];
char str_amount[32] = {0};
stellar_format_stroops(msg->limit, str_amount, sizeof(str_amount));
strlcat(str_amount_row, str_amount, sizeof(str_amount_row));
}
// Validate destination account and convert to bytes
uint8_t asset_issuer_bytes[STELLAR_KEY_SIZE];
uint8_t asset_issuer_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->asset.issuer, asset_issuer_bytes)) {
stellar_signingAbort(_("User canceled"));
fsm_sendFailure(FailureType_Failure_ProcessError,
@ -935,7 +935,7 @@ bool stellar_confirmAllowTrustOp(const StellarAllowTrustOp *msg) {
stellar_hashupdate_uint32(7);
// Add Trust: USD
char str_title[32];
char str_title[32] = {0};
if (msg->is_authorized) {
strlcpy(str_title, _("Allow Trust of"), sizeof(str_title));
} else {
@ -943,11 +943,11 @@ bool stellar_confirmAllowTrustOp(const StellarAllowTrustOp *msg) {
}
// Asset code
char str_asset_row[32];
char str_asset_row[32] = {0};
strlcpy(str_asset_row, msg->asset_code, sizeof(str_asset_row));
// Validate account and convert to bytes
uint8_t trusted_account_bytes[STELLAR_KEY_SIZE];
uint8_t trusted_account_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->trusted_account, trusted_account_bytes)) {
stellar_signingAbort(_("Invalid trusted account"));
return false;
@ -957,7 +957,7 @@ bool stellar_confirmAllowTrustOp(const StellarAllowTrustOp *msg) {
stellar_lineBreakAddress(trusted_account_bytes);
// By: G...
char str_by[32];
char str_by[32] = {0};
strlcpy(str_by, _("By: "), sizeof(str_by));
strlcat(str_by, str_trustor_rows[0], sizeof(str_by));
@ -974,13 +974,13 @@ bool stellar_confirmAllowTrustOp(const StellarAllowTrustOp *msg) {
stellar_hashupdate_uint32(msg->asset_type);
// asset code
if (msg->asset_type == 1) {
char code4[4 + 1];
char code4[4 + 1] = {0};
memzero(code4, sizeof(code4));
strlcpy(code4, msg->asset_code, sizeof(code4));
stellar_hashupdate_bytes((uint8_t *)code4, 4);
}
if (msg->asset_type == 2) {
char code12[12 + 1];
char code12[12 + 1] = {0};
memzero(code12, sizeof(code12));
strlcpy(code12, msg->asset_code, sizeof(code12));
stellar_hashupdate_bytes((uint8_t *)code12, 12);
@ -1006,7 +1006,7 @@ bool stellar_confirmAccountMergeOp(const StellarAccountMergeOp *msg) {
stellar_hashupdate_uint32(8);
// Validate account and convert to bytes
uint8_t destination_account_bytes[STELLAR_KEY_SIZE];
uint8_t destination_account_bytes[STELLAR_KEY_SIZE] = {0};
if (!stellar_getAddressBytes(msg->destination_account,
destination_account_bytes)) {
stellar_signingAbort(_("Invalid destination account"));
@ -1045,7 +1045,7 @@ bool stellar_confirmManageDataOp(const StellarManageDataOp *msg) {
// Hash: operation type
stellar_hashupdate_uint32(10);
char str_title[32];
char str_title[32] = {0};
if (msg->has_value) {
strlcpy(str_title, _("Set data value key:"), sizeof(str_title));
} else {
@ -1068,7 +1068,7 @@ bool stellar_confirmManageDataOp(const StellarManageDataOp *msg) {
if (msg->has_value) {
strlcpy(str_title, _("Confirm sha256 of value:"), sizeof(str_title));
char str_hash_digest[SHA256_DIGEST_STRING_LENGTH];
char str_hash_digest[SHA256_DIGEST_STRING_LENGTH] = {0};
sha256_Data(msg->value.bytes, msg->value.size, str_hash_digest);
const char **str_hash_lines = split_message(
(const uint8_t *)str_hash_digest, sizeof(str_hash_digest), 16);
@ -1110,7 +1110,7 @@ bool stellar_confirmBumpSequenceOp(const StellarBumpSequenceOp *msg) {
// Hash: operation type
stellar_hashupdate_uint32(11);
char str_bump_to[20];
char str_bump_to[20] = {0};
stellar_format_uint64(msg->bump_to, str_bump_to, sizeof(str_bump_to));
stellar_layoutTransactionDialog(_("Bump Sequence"), _("Set sequence to:"),
@ -1154,7 +1154,7 @@ void stellar_fillSignedTx(StellarSignedTx *resp) {
// Add the signature (note that this does not include the 4-byte hint since it
// can be calculated from the public key)
uint8_t signature[64];
uint8_t signature[64] = {0};
// Note: this calls sha256_Final on the hash context
stellar_getSignatureForActiveTx(signature);
memcpy(resp->signature.bytes, signature, sizeof(signature));
@ -1181,10 +1181,10 @@ void stellar_getSignatureForActiveTx(uint8_t *out_signature) {
// Signature is the ed25519 detached signature of the sha256 of all the bytes
// that have been read so far
uint8_t to_sign[32];
uint8_t to_sign[32] = {0};
sha256_Final(&(stellar_activeTx.sha256_ctx), to_sign);
uint8_t signature[64];
uint8_t signature[64] = {0};
ed25519_sign(to_sign, sizeof(to_sign), node->private_key,
node->public_key + 1, signature);
@ -1248,7 +1248,7 @@ void stellar_format_price(uint32_t numerator, uint32_t denominator, char *out,
* Returns a uint32 formatted as a string
*/
void stellar_format_uint32(uint32_t number, char *out, size_t outlen) {
bignum256 bn_number;
bignum256 bn_number = {0};
bn_read_uint32(number, &bn_number);
bn_format(&bn_number, NULL, NULL, 0, 0, false, out, outlen);
}
@ -1265,7 +1265,7 @@ void stellar_format_uint64(uint64_t number, char *out, size_t outlen) {
* This is to allow a small label to be prepended to the first line
*/
const char **stellar_lineBreakAddress(const uint8_t *addrbytes) {
char str_fulladdr[56 + 1];
char str_fulladdr[56 + 1] = {0};
static char rows[3][20 + 1];
memzero(rows, sizeof(rows));
@ -1292,9 +1292,9 @@ const char **stellar_lineBreakAddress(const uint8_t *addrbytes) {
*/
void stellar_format_asset(const StellarAssetType *asset, char *str_formatted,
size_t len) {
char str_asset_code[12 + 1];
char str_asset_code[12 + 1] = {0};
// truncated asset issuer, final length depends on length of asset code
char str_asset_issuer_trunc[13 + 1];
char str_asset_issuer_trunc[13 + 1] = {0};
memzero(str_formatted, len);
memzero(str_asset_code, sizeof(str_asset_code));
@ -1367,7 +1367,7 @@ size_t stellar_publicAddressAsStr(const uint8_t *bytes, char *out,
*/
bool stellar_validateAddress(const char *str_address) {
bool valid = false;
uint8_t decoded[STELLAR_ADDRESS_SIZE_RAW];
uint8_t decoded[STELLAR_ADDRESS_SIZE_RAW] = {0};
memzero(decoded, sizeof(decoded));
if (strlen(str_address) != STELLAR_ADDRESS_SIZE) {
@ -1400,7 +1400,7 @@ bool stellar_validateAddress(const char *str_address) {
* Converts a string address (G...) to the 32-byte raw address
*/
bool stellar_getAddressBytes(const char *str_address, uint8_t *out_bytes) {
uint8_t decoded[STELLAR_ADDRESS_SIZE_RAW];
uint8_t decoded[STELLAR_ADDRESS_SIZE_RAW] = {0};
memzero(decoded, sizeof(decoded));
// Ensure address is valid
@ -1426,11 +1426,11 @@ uint16_t stellar_crc16(uint8_t *bytes, uint32_t length) {
// Calculate checksum for existing bytes
uint16_t crc = 0x0000;
uint16_t polynomial = 0x1021;
uint32_t i;
uint8_t bit;
uint8_t byte;
uint8_t bitidx;
uint8_t c15;
uint32_t i = 0;
uint8_t bit = 0;
uint8_t byte = 0;
uint8_t bitidx = 0;
uint8_t c15 = 0;
for (i = 0; i < length; i++) {
byte = bytes[i];
@ -1478,7 +1478,7 @@ void stellar_hashupdate_uint32(uint32_t value) {
#endif
// Byte values must be hashed as big endian
uint8_t data[4];
uint8_t data[4] = {0};
data[3] = (value >> 24) & 0xFF;
data[2] = (value >> 16) & 0xFF;
data[1] = (value >> 8) & 0xFF;
@ -1494,7 +1494,7 @@ void stellar_hashupdate_uint64(uint64_t value) {
#endif
// Byte values must be hashed as big endian
uint8_t data[8];
uint8_t data[8] = {0};
data[7] = (value >> 56) & 0xFF;
data[6] = (value >> 48) & 0xFF;
data[5] = (value >> 40) & 0xFF;
@ -1550,7 +1550,7 @@ void stellar_hashupdate_asset(const StellarAssetType *asset) {
stellar_hashupdate_uint32(asset->type);
// For non-native assets, validate issuer account and convert to bytes
uint8_t issuer_bytes[STELLAR_KEY_SIZE];
uint8_t issuer_bytes[STELLAR_KEY_SIZE] = {0};
if (asset->type != 0 &&
!stellar_getAddressBytes(asset->issuer, issuer_bytes)) {
stellar_signingAbort(_("Invalid asset issuer"));
@ -1559,7 +1559,7 @@ void stellar_hashupdate_asset(const StellarAssetType *asset) {
// 4-character asset code
if (asset->type == 1) {
char code4[4 + 1];
char code4[4 + 1] = {0};
memzero(code4, sizeof(code4));
strlcpy(code4, asset->code, sizeof(code4));
@ -1569,7 +1569,7 @@ void stellar_hashupdate_asset(const StellarAssetType *asset) {
// 12-character asset code
if (asset->type == 2) {
char code12[12 + 1];
char code12[12 + 1] = {0};
memzero(code12, sizeof(code12));
strlcpy(code12, asset->code, sizeof(code12));
@ -1586,11 +1586,11 @@ void stellar_hashupdate_bytes(const uint8_t *data, size_t len) {
* Displays a summary of the overall transaction
*/
void stellar_layoutTransactionSummary(const StellarSignTx *msg) {
char str_lines[5][32];
char str_lines[5][32] = {0};
memzero(str_lines, sizeof(str_lines));
char str_fee[12];
char str_num_ops[12];
char str_fee[12] = {0};
char str_num_ops[12] = {0};
// Will be set to true for some large hashes that don't fit on one screen
uint8_t needs_memo_hash_confirm = 0;
@ -1680,8 +1680,8 @@ void stellar_layoutTransactionSummary(const StellarSignTx *msg) {
// Timebound: lower
if (msg->timebounds_start || msg->timebounds_end) {
time_t timebound;
char str_timebound[32];
const struct tm *tm;
char str_timebound[32] = {0};
const struct tm *tm = NULL;
timebound = (time_t)msg->timebounds_start;
strlcpy(str_lines[0], _("Valid from:"), sizeof(str_lines[0]));
@ -1749,7 +1749,7 @@ void stellar_layoutSigningDialog(const char *line1, const char *line2,
oledClear();
// Load up public address
char str_pubaddr[56 + 1];
char str_pubaddr[56 + 1] = {0};
memzero(str_pubaddr, sizeof(str_pubaddr));
stellar_publicAddressAsStr(node->public_key + 1, str_pubaddr,
sizeof(str_pubaddr));
@ -1757,7 +1757,7 @@ void stellar_layoutSigningDialog(const char *line1, const char *line2,
// Header
// Ends up as: Signing with GABCDEFGHIJKL
char str_header[32];
char str_header[32] = {0};
memzero(str_header, sizeof(str_header));
strlcpy(str_header, _("Signing with "), sizeof(str_header));
strlcat(str_header, str_pubaddr_truncated, sizeof(str_header));
@ -1805,7 +1805,7 @@ void stellar_layoutSigningDialog(const char *line1, const char *line2,
}
// Next / sign button
char str_next_label[8];
char str_next_label[8] = {0};
if (is_final_step) {
strlcpy(str_next_label, _("SIGN"), sizeof(str_next_label));
} else {
@ -1831,7 +1831,7 @@ void stellar_layoutSigningDialog(const char *line1, const char *line2,
void stellar_layoutTransactionDialog(const char *line1, const char *line2,
const char *line3, const char *line4,
const char *line5) {
char str_warning[16];
char str_warning[16] = {0};
memzero(str_warning, sizeof(str_warning));
if (stellar_activeTx.network_type == 2) {

@ -105,9 +105,9 @@ bool compute_address(const CoinInfo *coin, InputScriptType script_type,
const HDNode *node, bool has_multisig,
const MultisigRedeemScriptType *multisig,
char address[MAX_ADDR_SIZE]) {
uint8_t raw[MAX_ADDR_RAW_SIZE];
uint8_t digest[32];
size_t prelen;
uint8_t raw[MAX_ADDR_RAW_SIZE] = {0};
uint8_t digest[32] = {0};
size_t prelen = 0;
if (has_multisig) {
if (cryptoMultisigPubkeyIndex(coin, multisig, node->public_key) < 0) {
@ -200,8 +200,8 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in,
memzero(out, sizeof(TxOutputBinType));
out->amount = in->amount;
out->decred_script_version = in->decred_script_version;
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
size_t addr_raw_len;
uint8_t addr_raw[MAX_ADDR_RAW_SIZE] = {0};
size_t addr_raw_len = 0;
if (in->script_type == OutputScriptType_PAYTOOPRETURN) {
// only 0 satoshi allowed for OP_RETURN
@ -235,7 +235,7 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in,
if (in->address_n_count > 0) {
static CONFIDENTIAL HDNode node;
InputScriptType input_script_type;
InputScriptType input_script_type = 0;
switch (in->script_type) {
case OutputScriptType_PAYTOADDRESS:
@ -269,7 +269,7 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in,
addr_raw_len = base58_decode_check(in->address, coin->curve->hasher_base58,
addr_raw, MAX_ADDR_RAW_SIZE);
size_t prefix_len;
size_t prefix_len = 0;
if (coin->has_address_type // p2pkh
&& addr_raw_len ==
20 + (prefix_len = address_prefix_bytes_len(coin->address_type)) &&
@ -313,7 +313,7 @@ int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in,
return 0;
}
} else if (coin->bech32_prefix) {
int witver;
int witver = 0;
if (!segwit_addr_decode(&witver, addr_raw, &addr_raw_len,
coin->bech32_prefix, in->address)) {
return 0;
@ -394,10 +394,10 @@ uint32_t compile_script_multisig_hash(const CoinInfo *coin,
if (m < 1 || m > 15) return 0;
if (n < 1 || n > 15) return 0;
Hasher hasher;
Hasher hasher = {0};
hasher_Init(&hasher, coin->curve->hasher_script);
uint8_t d[2];
uint8_t d[2] = {0};
d[0] = 0x50 + m;
hasher_Update(&hasher, d, 1);
for (uint32_t i = 0; i < n; i++) {
@ -800,7 +800,7 @@ void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse) {
}
static uint32_t tx_input_script_size(const TxInputType *txinput) {
uint32_t input_script_size;
uint32_t input_script_size = 0;
if (txinput->has_multisig) {
uint32_t multisig_script_size =
TXSIZE_MULTISIGSCRIPT +
@ -860,9 +860,9 @@ uint32_t tx_output_weight(const CoinInfo *coin, const TxOutputType *txoutput) {
txoutput->has_multisig ? TXSIZE_P2SCRIPT : TXSIZE_P2PKHASH;
}
} else {
uint8_t addr_raw[MAX_ADDR_RAW_SIZE];
int witver;
size_t addr_raw_len;
uint8_t addr_raw[MAX_ADDR_RAW_SIZE] = {0};
int witver = 0;
size_t addr_raw_len = 0;
if (coin->cashaddr_prefix &&
cash_addr_decode(addr_raw, &addr_raw_len, coin->cashaddr_prefix,
txoutput->address)) {

@ -39,7 +39,7 @@
#endif
/* Screen timeout */
uint32_t system_millis_lock_start;
uint32_t system_millis_lock_start = 0;
void check_lock_screen(void) {
buttonUpdate();
@ -100,7 +100,7 @@ static void collect_hw_entropy(bool privileged) {
desig_get_unique_id((uint32_t *)HW_ENTROPY_DATA);
// set entropy in the OTP randomness block
if (!flash_otp_is_locked(FLASH_OTP_BLOCK_RANDOMNESS)) {
uint8_t entropy[FLASH_OTP_BLOCK_SIZE];
uint8_t entropy[FLASH_OTP_BLOCK_SIZE] = {0};
random_buffer(entropy, FLASH_OTP_BLOCK_SIZE);
flash_otp_write(FLASH_OTP_BLOCK_RANDOMNESS, 0, entropy,
FLASH_OTP_BLOCK_SIZE);

@ -174,7 +174,7 @@ void u2fhid_init_cmd(const U2FHID_FRAME *f) {
}
void u2fhid_read_start(const U2FHID_FRAME *f) {
U2F_ReadBuffer readbuffer;
U2F_ReadBuffer readbuffer = {0};
memzero(&readbuffer, sizeof(readbuffer));
if (!(f->type & TYPE_INIT)) {
@ -273,7 +273,7 @@ void u2fhid_wink(const uint8_t *buf, uint32_t len) {
if (dialog_timeout > 0) dialog_timeout = U2F_TIMEOUT;
U2FHID_FRAME f;
U2FHID_FRAME f = {0};
memzero(&f, sizeof(f));
f.cid = cid;
f.init.cmd = U2FHID_WINK;
@ -283,8 +283,8 @@ void u2fhid_wink(const uint8_t *buf, uint32_t len) {
void u2fhid_init(const U2FHID_FRAME *in) {
const U2FHID_INIT_REQ *init_req = (const U2FHID_INIT_REQ *)&in->init.data;
U2FHID_FRAME f;
U2FHID_INIT_RESP resp;
U2FHID_FRAME f = {0};
U2FHID_INIT_RESP resp = {0};
memzero(&resp, sizeof(resp));
debugLog(0, "", "u2fhid_init");
@ -367,10 +367,10 @@ void send_u2fhid_msg(const uint8_t cmd, const uint8_t *data,
return;
}
U2FHID_FRAME f;
U2FHID_FRAME f = {0};
uint8_t *p = (uint8_t *)data;
uint32_t l = len;
uint32_t psz;
uint32_t psz = 0;
uint8_t seq = 0;
// debugLog(0, "", "send_u2fhid_msg");
@ -405,7 +405,7 @@ void send_u2fhid_msg(const uint8_t cmd, const uint8_t *data,
}
void send_u2fhid_error(uint32_t fcid, uint8_t err) {
U2FHID_FRAME f;
U2FHID_FRAME f = {0};
memzero(&f, sizeof(f));
f.cid = fcid;
@ -470,10 +470,10 @@ static const HDNode *getDerivedNode(uint32_t *address_n,
static const HDNode *generateKeyHandle(const uint8_t app_id[],
uint8_t key_handle[]) {
uint8_t keybase[U2F_APPID_SIZE + KEY_PATH_LEN];
uint8_t keybase[U2F_APPID_SIZE + KEY_PATH_LEN] = {0};
// Derivation path is m/U2F'/r'/r'/r'/r'/r'/r'/r'/r'
uint32_t key_path[KEY_PATH_ENTRIES];
uint32_t key_path[KEY_PATH_ENTRIES] = {0};
for (uint32_t i = 0; i < KEY_PATH_ENTRIES; i++) {
// high bit for hardened keys
key_path[i] = 0x80000000 | random32();
@ -499,7 +499,7 @@ static const HDNode *generateKeyHandle(const uint8_t app_id[],
static const HDNode *validateKeyHandle(const uint8_t app_id[],
const uint8_t key_handle[]) {
uint32_t key_path[KEY_PATH_ENTRIES];
uint32_t key_path[KEY_PATH_ENTRIES] = {0};
memcpy(key_path, key_handle, KEY_PATH_LEN);
for (unsigned int i = 0; i < KEY_PATH_ENTRIES; i++) {
// check high bit for hardened keys
@ -511,11 +511,11 @@ static const HDNode *validateKeyHandle(const uint8_t app_id[],
const HDNode *node = getDerivedNode(key_path, KEY_PATH_ENTRIES);
if (!node) return NULL;
uint8_t keybase[U2F_APPID_SIZE + KEY_PATH_LEN];
uint8_t keybase[U2F_APPID_SIZE + KEY_PATH_LEN] = {0};
memcpy(&keybase[0], app_id, U2F_APPID_SIZE);
memcpy(&keybase[U2F_APPID_SIZE], key_handle, KEY_PATH_LEN);
uint8_t hmac[SHA256_DIGEST_LENGTH];
uint8_t hmac[SHA256_DIGEST_LENGTH] = {0};
hmac_sha256(node->private_key, sizeof(node->private_key), keybase,
sizeof(keybase), hmac);
@ -558,7 +558,7 @@ void u2f_register(const APDU *a) {
_("Another U2F device"), _("was used to register"),
_("in this application."), NULL, NULL, NULL);
} else {
const char *appname;
const char *appname = NULL;
getReadableAppId(req->appId, &appname);
layoutU2FDialog(_("Register"), appname);
}
@ -575,7 +575,7 @@ void u2f_register(const APDU *a) {
// Buttons said yes
if (last_req_state == REG_PASS) {
uint8_t data[sizeof(U2F_REGISTER_RESP) + 2];
uint8_t data[sizeof(U2F_REGISTER_RESP) + 2] = {0};
U2F_REGISTER_RESP *resp = (U2F_REGISTER_RESP *)&data;
memzero(data, sizeof(data));
@ -597,8 +597,8 @@ void u2f_register(const APDU *a) {
memcpy(resp->keyHandleCertSig + resp->keyHandleLen, U2F_ATT_CERT,
sizeof(U2F_ATT_CERT));
uint8_t sig[64];
U2F_REGISTER_SIG_STR sig_base;
uint8_t sig[64] = {0};
U2F_REGISTER_SIG_STR sig_base = {0};
sig_base.reserved = 0;
memcpy(sig_base.appId, req->appId, U2F_APPID_SIZE);
memcpy(sig_base.chal, req->chal, U2F_CHAL_SIZE);
@ -690,7 +690,7 @@ void u2f_authenticate(const APDU *a) {
if (last_req_state == INIT) {
// error: testof-user-presence is required
buttonUpdate(); // Clear button state
const char *appname;
const char *appname = NULL;
getReadableAppId(req->appId, &appname);
layoutU2FDialog(_("Authenticate"), appname);
last_req_state = AUTH;
@ -706,7 +706,7 @@ void u2f_authenticate(const APDU *a) {
// Buttons said yes
if (last_req_state == AUTH_PASS) {
uint8_t buf[sizeof(U2F_AUTHENTICATE_RESP) + 2];
uint8_t buf[(sizeof(U2F_AUTHENTICATE_RESP)) + 2] = {0};
U2F_AUTHENTICATE_RESP *resp = (U2F_AUTHENTICATE_RESP *)&buf;
const uint32_t ctr = config_nextU2FCounter();
@ -717,8 +717,8 @@ void u2f_authenticate(const APDU *a) {
resp->ctr[3] = ctr & 0xff;
// Build and sign response
U2F_AUTHENTICATE_SIG_STR sig_base;
uint8_t sig[64];
U2F_AUTHENTICATE_SIG_STR sig_base = {0};
uint8_t sig[64] = {0};
memcpy(sig_base.appId, req->appId, U2F_APPID_SIZE);
sig_base.flags = resp->flags;
memcpy(sig_base.ctr, resp->ctr, 4);
@ -744,7 +744,7 @@ void u2f_authenticate(const APDU *a) {
}
void send_u2f_error(const uint16_t err) {
uint8_t data[2];
uint8_t data[2] = {0};
data[0] = err >> 8 & 0xFF;
data[1] = err & 0xFF;
send_u2f_msg(data, 2);

@ -16,7 +16,7 @@ static inline char convert(char c) {
}
int main(int argc, char **argv) {
char *line;
char *line = NULL;
int font = FONT_STANDARD;
while ((line = readline(NULL)) != NULL) {
size_t length = strlen(line);

@ -25,8 +25,8 @@
static uint16_t build_bos_descriptor(const struct usb_bos_descriptor *bos,
uint8_t *buf, uint16_t len) {
uint8_t *tmpbuf = buf;
uint16_t count, total = 0, totallen = 0;
uint16_t i;
uint16_t count = 0, total = 0, totallen = 0;
uint16_t i = 0;
memcpy(buf, bos, count = MIN(len, bos->bLength));
buf += count;

@ -45,7 +45,7 @@ LGPL License Terms @ref lgpl_license
int usbd_register_set_config_callback(usbd_device *usbd_dev,
usbd_set_config_callback callback)
{
int i;
int i = 0;
for (i = 0; i < MAX_USER_SET_CONFIG_CALLBACK; i++) {
if (usbd_dev->user_callback_set_config[i]) {
@ -73,8 +73,8 @@ static uint16_t build_config_descriptor(usbd_device *usbd_dev,
{
uint8_t *tmpbuf = buf;
const struct usb_config_descriptor *cfg = &usbd_dev->config[index];
uint16_t count, total = 0, totallen = 0;
uint16_t i, j, k;
uint16_t count = 0, total = 0, totallen = 0;
uint16_t i = 0, j = 0, k = 0;
memcpy(buf, cfg, count = MIN(len, cfg->bLength));
buf += count;
@ -160,8 +160,8 @@ usb_standard_get_descriptor(usbd_device *usbd_dev,
wait_random();
int i, array_idx, descr_idx;
struct usb_string_descriptor *sd;
int i = 0, array_idx = 0, descr_idx = 0;
struct usb_string_descriptor *sd = NULL;
descr_idx = usb_descriptor_index(req->wValue);
@ -259,9 +259,9 @@ usb_standard_set_configuration(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len)
{
unsigned i;
unsigned i = 0;
int found_index = -1;
const struct usb_config_descriptor *cfg;
const struct usb_config_descriptor *cfg = NULL;
(void)req;
(void)buf;
@ -344,7 +344,7 @@ usb_standard_set_interface(usbd_device *usbd_dev,
{
const struct usb_config_descriptor *cfx =
&usbd_dev->config[usbd_dev->current_config - 1];
const struct usb_interface *iface;
const struct usb_interface *iface = NULL;
(void)buf;
@ -380,7 +380,7 @@ usb_standard_get_interface(usbd_device *usbd_dev,
struct usb_setup_data *req,
uint8_t **buf, uint16_t *len)
{
uint8_t *cur_altsetting;
uint8_t *cur_altsetting = NULL;
const struct usb_config_descriptor *cfx =
&usbd_dev->config[usbd_dev->current_config - 1];

Loading…
Cancel
Save