static analysis fixes

pull/11/head
kaleb-himes 2015-06-27 23:18:53 -06:00
parent 99163fe6fc
commit 555f288ee9
3 changed files with 18 additions and 7 deletions

View File

@ -35,7 +35,7 @@ int wolfsslBenchmark(int timer, int* option)
int i = 0; /* A looping variable */
int loop = 1; /* benchmarking loop */
int64_t blocks = 0; /* blocks used during benchmarking */
int64_t blocks = 0; /* blocks used during benchmarking */
#ifndef NO_AES
Aes aes; /* aes declaration */
#endif
@ -46,7 +46,7 @@ int wolfsslBenchmark(int timer, int* option)
RNG rng; /* random number generator */
int ret = 0; /* return variable */
int ret = 0; /* return variable */
double stop = 0.0; /* stop breaks loop */
double start; /* start time */
double currTime; /* current time*/

View File

@ -43,17 +43,18 @@ int wolfsslDecrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
FILE* outFile; /* output file */
RNG rng; /* random number generator */
byte* input; /* input buffer */
byte* output; /* output buffer */
byte* input = NULL; /* input buffer */
byte* output = NULL; /* output buffer */
byte salt[SALT_SIZE] = {0}; /* salt variable */
int currLoopFlag = 1; /* flag to track the loop */
int lastLoopFlag = 0; /* flag for last loop */
int ret = 0; /* return variable */
int keyVerify = 0; /* verify the key is set */
int i = 0; /* loop variable */
int pad = 0; /* the length to pad */
int length; /* length of message */
int tempMax = MAX; /* equal to MAX until feof */
int keyVerify = 0; /* verify the key is set */
int i = 0; /* loop variable */
int sbSize = SALT_SIZE + block; /* size of salt and iv together */
/* opens input file */
@ -208,7 +209,7 @@ int wolfsslDecrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
if (currLoopFlag == lastLoopFlag) {
if (salt[0] != 0) {
/* reduces length based on number of padded elements */
int pad = output[tempMax-1];
pad = output[tempMax-1];
/* adjust length for padded bytes and salt size */
length -= pad + sbSize;
/* reset tempMax for smaller decryption */

View File

@ -264,10 +264,20 @@ int wolfsslEncrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
if (ferror(outFile)) {
printf("failed to write to file.\n");
if (input != NULL)
XMEMSET(input, 0, tempMax);
if (output != NULL)
XMEMSET(output, 0, tempMax);
wolfsslFreeBins(input, output, NULL, NULL, NULL);
return FWRITE_ERROR;
}
if (ret > MAX) {
printf("Wrote too much to file.\n");
if (input != NULL)
XMEMSET(input, 0, tempMax);
if (output != NULL)
XMEMSET(output, 0, tempMax);
wolfsslFreeBins(input, output, NULL, NULL, NULL);
return FWRITE_ERROR;
}
/* close the outFile */