Coverity scan fixes

This commit is contained in:
J Harper
2016-05-03 17:36:14 -07:00
parent b7583a12f6
commit ac16cf8a1b
64 changed files with 306 additions and 394 deletions

View File

@@ -8,23 +8,23 @@
#
MATRIXSSL_ROOT:=../..
VECTOR_SRC:=algorithmTest.c
SPEED_SRC:=throughputTest.c
SRC:=$(VECTOR_SRC) $(SPEED_SRC)
SRC:=$(VECTOR_SRC) $(SPEED_SRC)
VECTOR_EXE:=algorithmTest$(E)
SPEED_EXE:=throughputTest$(E)
EXE:=$(VECTOR_EXE) $(SPEED_EXE)
include $(MATRIXSSL_ROOT)/common.mk
# Generated files
VECTOR_EXE:=algorithmTest$(E)
SPEED_EXE:=throughputTest$(E)
# Linked files
STATICS:=../libcrypt_s.a $(MATRIXSSL_ROOT)/core/libcore_s.a
#STATICS+=$(MATRIXSSL_ROOT)/matrixssl/libssl_s.a
all: compile
compile: $(OBJS) $(SPEED_EXE) $(VECTOR_EXE)
compile: $(OBJS) $(EXE)
$(MAKE) --directory=rsaperf
$(MAKE) --directory=eccperf
$(MAKE) --directory=dhperf
@@ -38,17 +38,8 @@ $(SPEED_EXE): $(SPEED_SRC:.c=.o) $(STATICS)
$(VECTOR_EXE): $(VECTOR_SRC:.c=.o) $(STATICS)
$(CC) -o $@ $^ $(LDFLAGS)
ifneq (,$(findstring -octeon,$(CCARCH)))
SIM:=oct-sim
SIMFLAGS:=-quiet -numcores=1 -noperf
endif
test:
$(SIM) ./$(VECTOR_EXE) $(SIMFLAGS)
clean:
rm -f $(VECTOR_EXE) $(SPEED_EXE) $(OBJS)
rm -f $(EXE) $(OBJS)
$(MAKE) clean --directory=rsaperf
$(MAKE) clean --directory=eccperf
$(MAKE) clean --directory=dhperf

View File

@@ -86,11 +86,6 @@ static int32 psPrngTests(void)
return res < 0 ? res : PS_SUCCESS;
}
/******************************************************************************/
#ifdef USE_AES
#define AES_ITER 1000 /* For AES Block mode test */
@@ -893,10 +888,6 @@ int32 psAesTestGCM(void)
}
#endif /* USE_AES_GCM */
#endif /* USE_AES */
#if 0
@@ -2474,7 +2465,6 @@ static int32 psRsaEncryptTest(void)
i++) {
_psTraceInt(" %d bit test...", rsa[i].size * 8);
/* Start with getting both key halfs from the same source */
if (psRsaInitKey(pool, &privkey) < 0) {
return -1;
@@ -2519,7 +2509,6 @@ static int32 psRsaEncryptTest(void)
} /* key loop */
return PS_SUCCESS;
}
@@ -2542,7 +2531,6 @@ static int32 psRsaSignTest(void)
i++) {
_psTraceInt(" %d bit test...", rsa[i].size * 8);
psRsaInitKey(pool, &privkey);
psRsaParsePkcs1PrivKey(pool, rsa[i].key, rsa[i].keysize, &privkey);
if (psRsaEncryptPriv(pool, &privkey, in, sizeof(in), out, rsa[i].size,
@@ -4524,7 +4512,6 @@ static int32_t psEccTest(void)
/******************************************************************************/
/******************************************************************************/
typedef struct {
@@ -4690,7 +4677,6 @@ static test_t tests[] = {
{NULL
, "***** PRF2 TESTS *****"},
{NULL, ""}
};

View File

@@ -130,7 +130,6 @@ static keyList_t keys[] = {
Main
*/
int main(int argc, char **argv)
{
psPool_t *pool, *misc;

View File

@@ -199,7 +199,6 @@ const static keyList_t keys[] = {
Main
*/
#ifdef STATS
#include <unistd.h>
#include <fcntl.h>
@@ -250,6 +249,7 @@ int main(int argc, char **argv)
if (psEccParsePrivKey(misc, (unsigned char*)keys[i].key, keys[i].len,
&privkey, NULL) < 0) {
_psTrace(" FAILED OPERATION:ParsePriv\n");
exit(0);
}
/* Get random data to sign */

View File

@@ -336,7 +336,6 @@ static keyList_t keys[] = {
Main
*/
#ifdef STATS
#include <fcntl.h>
#ifdef USE_HIGHRES_TIME
@@ -451,6 +450,7 @@ int main(int argc, char **argv)
memset(in, 0x0, keysize);
psGetTime(&start, NULL);
/* coverity[swapped_arguments] */
if (psRsaDecryptPub(pool, &privkey, out, keysize, in, 5, pkaInfo) < 0) {
_psTrace(" FAILED VERIFY OPERATION\n");
}
@@ -538,7 +538,6 @@ int main(int argc, char **argv)
i++;
}
#ifdef STATS
fclose(sfd);
#endif

View File

@@ -49,7 +49,6 @@ static unsigned char key[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f };
enum {
AES_ENC_ALG = 1,
AES_DEC_ALG,
@@ -132,6 +131,7 @@ static void runWithHmac(psCipherContext_t *ctx, psHmac_t *hmac,
#endif
default:
printf("Skipping HMAC Test\n");
psFree(dataChunk, NULL);
return;
}
@@ -147,6 +147,7 @@ static void runWithHmac(psCipherContext_t *ctx, psHmac_t *hmac,
printf("%d byte chunks in %d msecs total for rate of %d MB/sec\n",
chunk, diffm, round);
#endif
psFree(dataChunk, NULL);
}
#endif /* USE_HMAC */
@@ -241,6 +242,7 @@ static void runTime(psCipherContext_t *ctx, psCipherGivContext_t *ctx_giv,
break;
#endif
default:
psFree(dataChunk, NULL);
return;
}
@@ -620,6 +622,7 @@ void runDigestTime(psDigestContext_t *ctx, int32 chunk, int32 alg)
break;
#endif
default:
psFree(dataChunk, NULL);
printf("Skipping Digest Tests\n");
return;
}
@@ -636,7 +639,7 @@ void runDigestTime(psDigestContext_t *ctx, int32 chunk, int32 alg)
printf("%d byte chunks in %d msecs total for rate of %d MB/sec\n",
chunk, diffm, round);
#endif
psFree(dataChunk, NULL);
}
/******************************************************************************/