Merge pull request #77 from kaleb-himes/warning-fixes
Fix some warnings thrown by -Wpointer-signpull/78/head
commit
6f109a5330
|
@ -22,7 +22,7 @@
|
|||
#include "clu_include/clu_header_main.h"
|
||||
#include "clu_include/genkey/clu_genkey.h"
|
||||
|
||||
#define MAX 1024
|
||||
#define MAX_LEN 1024
|
||||
|
||||
int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
||||
char* in, char* out, byte* iv, int block, int keyType)
|
||||
|
@ -54,7 +54,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
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 tempMax = MAX_LEN; /* equal to MAX_LEN until feof */
|
||||
int sbSize = SALT_SIZE + block; /* size of salt and iv together */
|
||||
|
||||
/* opens input file */
|
||||
|
@ -78,17 +78,17 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
/* if there is a remainder,
|
||||
* round up else no round
|
||||
*/
|
||||
if (length % MAX > 0) {
|
||||
lastLoopFlag = (length/MAX) + 1;
|
||||
if (length % MAX_LEN > 0) {
|
||||
lastLoopFlag = (length/MAX_LEN) + 1;
|
||||
}
|
||||
else {
|
||||
lastLoopFlag = length/MAX;
|
||||
lastLoopFlag = length/MAX_LEN;
|
||||
}
|
||||
|
||||
input = (byte*) XMALLOC(MAX, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
input = (byte*) XMALLOC(MAX_LEN, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (input == NULL)
|
||||
return MEMORY_E;
|
||||
output = (byte*) XMALLOC(MAX, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
output = (byte*) XMALLOC(MAX_LEN, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (output == NULL) {
|
||||
wolfCLU_freeBins(input, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
}
|
||||
|
||||
/* Read in 1kB */
|
||||
if ((ret = (int) fread(input, 1, MAX, inFile)) != MAX) {
|
||||
if ((ret = (int) fread(input, 1, MAX_LEN, inFile)) != MAX_LEN) {
|
||||
if (feof(inFile)) {
|
||||
tempMax = ret;
|
||||
}
|
||||
|
@ -239,8 +239,8 @@ int wolfCLU_decrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
length -= tempMax;
|
||||
}
|
||||
/* closes the opened files and frees memory */
|
||||
XMEMSET(input, 0, MAX);
|
||||
XMEMSET (output, 0, MAX);
|
||||
XMEMSET(input, 0, MAX_LEN);
|
||||
XMEMSET (output, 0, MAX_LEN);
|
||||
wolfCLU_freeBins(input, output, NULL, NULL, NULL);
|
||||
XMEMSET(key, 0, size);
|
||||
/* Use the wolfssl wc_FreeRng to free rng */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "clu_include/clu_header_main.h"
|
||||
#include "clu_include/genkey/clu_genkey.h"
|
||||
|
||||
#define MAX 1024
|
||||
#define MAX_LEN 1024
|
||||
|
||||
int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
||||
char* in, char* out, byte* iv, int block, int ivCheck, int inputHex)
|
||||
|
@ -57,9 +57,9 @@ int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
int hexRet = 0; /* hex -> bin return*/
|
||||
|
||||
word32 tempInputL = 0; /* temporary input Length */
|
||||
word32 tempMax = MAX; /* controls encryption amount */
|
||||
word32 tempMax = MAX_LEN; /* controls encryption amount */
|
||||
|
||||
char inputString[MAX]; /* the input string */
|
||||
char inputString[MAX_LEN]; /* the input string */
|
||||
char* userInputBuffer = NULL; /* buffer when input is not a file */
|
||||
|
||||
|
||||
|
@ -142,10 +142,10 @@ int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
fclose(outFile);
|
||||
|
||||
/* MALLOC 1kB buffers */
|
||||
input = (byte*) XMALLOC(MAX, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
input = (byte*) XMALLOC(MAX_LEN, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (input == NULL)
|
||||
return MEMORY_E;
|
||||
output = (byte*) XMALLOC(MAX, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
output = (byte*) XMALLOC(MAX_LEN, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (output == NULL) {
|
||||
wolfCLU_freeBins(input, NULL, NULL, NULL, NULL);
|
||||
return MEMORY_E;
|
||||
|
@ -155,11 +155,11 @@ int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
while (length > 0) {
|
||||
/* Read in 1kB to input[] */
|
||||
if (inputHex == 1)
|
||||
ret = (int) fread(inputString, 1, MAX, inFile);
|
||||
ret = (int) fread(inputString, 1, MAX_LEN, inFile);
|
||||
else
|
||||
ret = (int) fread(input, 1, MAX, inFile);
|
||||
ret = (int) fread(input, 1, MAX_LEN, inFile);
|
||||
|
||||
if (ret != MAX) {
|
||||
if (ret != MAX_LEN) {
|
||||
/* check for end of file */
|
||||
if (feof(inFile)) {
|
||||
|
||||
|
@ -280,7 +280,7 @@ int wolfCLU_encrypt(char* alg, char* mode, byte* pwdKey, byte* key, int size,
|
|||
wolfCLU_freeBins(input, output, NULL, NULL, NULL);
|
||||
return FWRITE_ERROR;
|
||||
}
|
||||
if (ret > MAX) {
|
||||
if (ret > MAX_LEN) {
|
||||
printf("Wrote too much to file.\n");
|
||||
if (input != NULL)
|
||||
XMEMSET(input, 0, tempMax);
|
||||
|
|
|
@ -161,7 +161,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
char* fOutNameBuf = NULL;
|
||||
|
||||
size_t maxDerBufSz = 4 * keySz * AES_BLOCK_SIZE;
|
||||
char* derBuf = NULL;
|
||||
byte* derBuf = NULL;
|
||||
int derBufSz = -1;
|
||||
|
||||
if (rng == NULL || fName == NULL)
|
||||
|
@ -196,7 +196,7 @@ int wolfCLU_genKey_ECC(RNG* rng, char* fName, int directive, int fmt,
|
|||
XMEMSET(fOutNameBuf, 0, fNameSz + fExtSz);
|
||||
XMEMCPY(fOutNameBuf, fName, fNameSz);
|
||||
|
||||
derBuf = (char*)XMALLOC(maxDerBufSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
derBuf = (byte*) XMALLOC(maxDerBufSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (derBuf == NULL) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return MEMORY_E;
|
||||
|
@ -300,7 +300,7 @@ int wolfCLU_genKey_RSA(RNG* rng, char* fName, int directive, int fmt, int
|
|||
char* fOutNameBuf = NULL;
|
||||
|
||||
size_t maxDerBufSz = 5 * keySz * AES_BLOCK_SIZE;
|
||||
char* derBuf = NULL;
|
||||
byte* derBuf = NULL;
|
||||
int derBufSz = -1;
|
||||
|
||||
if (rng == NULL || fName == NULL)
|
||||
|
@ -331,7 +331,7 @@ int wolfCLU_genKey_RSA(RNG* rng, char* fName, int directive, int fmt, int
|
|||
XMEMSET(fOutNameBuf, 0, fNameSz + fExtSz);
|
||||
XMEMCPY(fOutNameBuf, fName, fNameSz);
|
||||
|
||||
derBuf = (char*)XMALLOC(maxDerBufSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
derBuf = (byte*) XMALLOC(maxDerBufSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (derBuf == NULL) {
|
||||
XFREE(fOutNameBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return MEMORY_E;
|
||||
|
|
Loading…
Reference in New Issue