Fixes for issues/warnings reported in issue #4.

This commit is contained in:
Moinak Ghosh 2013-02-15 22:53:17 +05:30
parent 24d62bfde9
commit f89473d29c
5 changed files with 27 additions and 7 deletions

View file

@ -489,8 +489,8 @@ slab_free(void *p, void *address)
}
if (!found) {
pthread_mutex_unlock(&hbucket_locks[hindx]);
free(address);
fprintf(stderr, "Freed buf(%p) not in slab allocations!\n", address);
free(address);
abort();
fflush(stderr);
}

View file

@ -737,6 +737,7 @@ init_crypto(crypto_ctx_t *cctx, uchar_t *pwd, int pwd_len, int crypto_alg,
if (saltlen > MAX_SALTLEN) {
fprintf(stderr, "Salt too long. Max allowed length is %d\n",
MAX_SALTLEN);
free(actx);
return (-1);
}
cctx->salt = (uchar_t *)malloc(saltlen);

View file

@ -105,6 +105,7 @@ genShortMsg(int hashbitlen)
sprintf(fn, "ShortMsgKAT_%d.txt", hashbitlen);
if ( (fp_out = fopen(fn, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fn);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fn);
@ -114,6 +115,8 @@ genShortMsg(int hashbitlen)
}
else {
printf("genShortMsg: Couldn't read Algorithm Name\n");
fclose(fp_in);
fclose(fp_out);
return KAT_HEADER_ERROR;
}
if ( FindMarker(fp_in, "# Principal Submitter:") ) {
@ -175,6 +178,7 @@ genShortMsgSponge(unsigned int rate, unsigned int capacity, int outputLength, co
if ( (fp_out = fopen(fileName, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fileName);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fileName);
@ -184,6 +188,8 @@ genShortMsgSponge(unsigned int rate, unsigned int capacity, int outputLength, co
}
else {
printf("genShortMsg: Couldn't read Algorithm Name\n");
fclose(fp_in);
fclose(fp_out);
return KAT_HEADER_ERROR;
}
if ( FindMarker(fp_in, "# Principal Submitter:") ) {
@ -248,6 +254,7 @@ genLongMsg(int hashbitlen)
sprintf(fn, "LongMsgKAT_%d.txt", hashbitlen);
if ( (fp_out = fopen(fn, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fn);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fn);
@ -257,6 +264,8 @@ genLongMsg(int hashbitlen)
}
else {
printf("genLongMsg: Couldn't read Algorithm Name\n");
fclose(fp_in);
fclose(fp_out);
return KAT_HEADER_ERROR;
}
if ( FindMarker(fp_in, "# Principal Submitter:") ) {
@ -332,6 +341,7 @@ genExtremelyLongMsg(int hashbitlen)
sprintf(fn, "ExtremelyLongMsgKAT_%d.txt", hashbitlen);
if ( (fp_out = fopen(fn, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fn);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fn);
@ -341,6 +351,8 @@ genExtremelyLongMsg(int hashbitlen)
}
else {
printf("genExtremelyLongMsg: Couldn't read Algorithm Name\n");
fclose(fp_in);
fclose(fp_out);
return KAT_HEADER_ERROR;
}
if ( FindMarker(fp_in, "# Principal Submitter:") ) {
@ -419,6 +431,7 @@ genMonteCarlo(int hashbitlen)
sprintf(fn, "MonteCarlo_%d.txt", hashbitlen);
if ( (fp_out = fopen(fn, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fn);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fn);
@ -428,6 +441,8 @@ genMonteCarlo(int hashbitlen)
}
else {
printf("genMonteCarlo: Couldn't read Algorithm Name\n");
fclose(fp_in);
fclose(fp_out);
return KAT_HEADER_ERROR;
}
if ( FindMarker(fp_in, "# Principal Submitter:") ) {
@ -484,6 +499,7 @@ genMonteCarloSqueezing(int hashbitlen)
sprintf(fn, "MonteCarlo_%d.txt", hashbitlen);
if ( (fp_out = fopen(fn, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fn);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fn);
@ -493,6 +509,8 @@ genMonteCarloSqueezing(int hashbitlen)
}
else {
printf("genMonteCarlo: Couldn't read Algorithm Name\n");
fclose(fp_in);
fclose(fp_out);
return KAT_HEADER_ERROR;
}
if ( FindMarker(fp_in, "# Principal Submitter:") ) {
@ -558,6 +576,7 @@ genDuplexKAT(unsigned int rate, unsigned int capacity, const char *fileName)
if ( (fp_out = fopen(fileName, "w")) == NULL ) {
printf("Couldn't open <%s> for write\n", fileName);
fclose(fp_in);
return KAT_FILE_OPEN_ERROR;
}
fprintf(fp_out, "# %s\n", fileName);

View file

@ -111,19 +111,19 @@ get_cksum_type(char *cksum_name)
if (strcmp(cksum_name, "SHA256") == 0) {
return (CKSUM_SHA256);
} else if (cksum_name, "SHA512") == 0) {
} else if (strcmp(cksum_name, "SHA512") == 0) {
return (CKSUM_SHA512);
} else if (cksum_name, "BLAKE256") == 0) {
} else if (strcmp(cksum_name, "BLAKE256") == 0) {
return (CKSUM_BLAKE256);
} else if (cksum_name, "BLAKE512") == 0) {
} else if (strcmp(cksum_name, "BLAKE512") == 0) {
return (CKSUM_BLAKE512);
} else if (cksum_name, "KECCAK256") == 0) {
} else if (strcmp(cksum_name, "KECCAK256") == 0) {
return (CKSUM_KECCAK256);
} else if (cksum_name, "KECCAK512") == 0) {
} else if (strcmp(cksum_name, "KECCAK512") == 0) {
return (CKSUM_KECCAK512);
}
return (CKSUM_INVALID);

View file

@ -526,7 +526,7 @@ dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size, uint64_t of
if (ctx->delta_flag) {
uint64_t cur_sketch;
uint64_t pc[3];
uint64_t pc[4];
if (length > ctx->rabin_poly_min_block_size) {
memcpy(ctx_heap, buf1+last_offset, length);