FIX: Some Coverity Scan warnings. fread, not initialised etc etc

This commit is contained in:
iceman1001
2016-04-23 18:23:46 +02:00
parent 5bb6228386
commit cd777a0545
7 changed files with 81 additions and 88 deletions

View File

@@ -383,7 +383,7 @@ uint32_t lfsr_rollback_word(struct Crypto1State *s, uint32_t in, int fb)
/** nonce_distance
* x,y valid tag nonces, then prng_successor(x, nonce_distance(x, y)) = y
*/
static uint16_t *dist = 0;
static uint16_t *dist;
int nonce_distance(uint32_t from, uint32_t to)
{
uint16_t x, i;
@@ -391,7 +391,7 @@ int nonce_distance(uint32_t from, uint32_t to)
dist = malloc(2 << 16);
if(!dist)
return -1;
for (x = i = 1; i; ++i) {
for (x = 1, i = 1; i; ++i) {
dist[(x & 0xff) << 8 | x >> 8] = i;
x = x >> 1 | (x ^ x >> 2 ^ x >> 3 ^ x >> 5) << 15;
}

View File

@@ -80,7 +80,7 @@ inline const bitslice_value_t crypto1_bs_lfsr_rollback(const bitslice_value_t in
// note that bytes are sliced and unsliced with reversed endianness
inline void crypto1_bs_convert_states(bitslice_t bitsliced_states[], state_t regular_states[]){
size_t bit_idx = 0, slice_idx = 0;
state_t values[MAX_BITSLICES];
state_t values[MAX_BITSLICES] = {{0x00}};
for(slice_idx = 0; slice_idx < MAX_BITSLICES; slice_idx++){
for(bit_idx = 0; bit_idx < STATE_SIZE; bit_idx++){
bool bit = get_vector_bit(slice_idx, bitsliced_states[bit_idx]);
@@ -111,7 +111,7 @@ void crypto1_bs_bitslice_value32(uint32_t value, bitslice_t bitsliced_value[], s
void crypto1_bs_print_states(bitslice_t bitsliced_states[]){
size_t slice_idx = 0;
state_t values[MAX_BITSLICES];
state_t values[MAX_BITSLICES] = {{0x00}};
crypto1_bs_convert_states(bitsliced_states, values);
for(slice_idx = 0; slice_idx < MAX_BITSLICES; slice_idx++){
printf("State %03zu: %012"llx"\n", slice_idx, values[slice_idx].value);

View File

@@ -58,7 +58,7 @@ bitslice_t bs_zeroes;
#define ROLLBACK_SIZE 8
// number of nonces required to test to cover entire 48-bit state
// I would have said it's 12... but bla goes with 100, so I do too
#define NONCE_TESTS 100
#define NONCE_TESTS 12
// state pointer management
extern __thread bitslice_t states[KEYSTREAM_SIZE+STATE_SIZE];