Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sizeof(pointer) fixes #36

Open
wants to merge 4 commits into
base: current
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bpv7/utils/bptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void print(statusReport *rpt){
printf("%u/%u ", rpt->creationCount, rpt->fragmentOffset);
char* buffer = malloc(32);
printf("%8s at %s on %s, '%s'.\n",
statusToString(rpt->statusFlags, buffer, sizeof(buffer)), tmbuffer, rpt->bundleSourceEid,
statusToString(rpt->statusFlags, buffer, 32), tmbuffer, rpt->bundleSourceEid,
rpt->reasonString);
free(buffer);
printDBG(3, "statusTime: " UVAST_FIELDSPEC "<=> %s\n", rpt->statusTime, tmbuffer);
Expand Down
2 changes: 1 addition & 1 deletion ici/library/platform_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ static SemaphoreTable *_semTbl(int action)

default: /* New SemaphoreTable. */
memset((char *) semaphoreTable, 0,
sizeof(semaphoreTable));
sizeof(SemaphoreTable));
}
}

Expand Down
13 changes: 7 additions & 6 deletions tc/dtka/dtka.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ int generateHMACKey(int keysize, unsigned char *buf)
return result;
}

/* buf and private_buf should be at least keysize bytes in size */
int generateECDSAKey(int keysize, unsigned char *buf, unsigned char *private_buf)
{
mbedtls_ecdsa_context ecdsa_context;
Expand Down Expand Up @@ -209,8 +210,8 @@ int generateECDSAKey(int keysize, unsigned char *buf, unsigned char *private_buf

// Extract keys from context
mbedtls_ecp_point_write_binary(&ecdsa_context.grp, &ecdsa_context.Q,
MBEDTLS_ECP_PF_UNCOMPRESSED, &len, buf, sizeof(buf));
mbedtls_ecp_write_key(&ecdsa_context, private_buf, sizeof(private_buf));
MBEDTLS_ECP_PF_UNCOMPRESSED, &len, buf, keysize);
mbedtls_ecp_write_key(&ecdsa_context, private_buf, keysize);

mbedtls_entropy_free(&entropy);
mbedtls_ctr_drbg_free(&ctr_drbg);
Expand All @@ -231,10 +232,10 @@ static int generateKeyPair(BpSAP sap, DtkaDB *db, char *keyType, int keySize)
#else /* For regression testing only. */
int key;
#endif
unsigned char *pubKeyBuf = malloc(sizeof(unsigned char) * keySize);
unsigned char *pubKeyBuf = malloc(keySize);
unsigned short publicKeyLen;
unsigned char *publicKey;
unsigned char *privKeyBuf = malloc(sizeof(unsigned char) * keySize);
unsigned char *privKeyBuf = malloc(keySize);
unsigned short privateKeyLen;
unsigned char *privateKey;
char recordBuffer[TC_MAX_REC];
Expand Down Expand Up @@ -274,7 +275,7 @@ static int generateKeyPair(BpSAP sap, DtkaDB *db, char *keyType, int keySize)
}

publicKeyLen = keySize;
publicKey = (pubKeyBuf + (sizeof pubKeyBuf - 1)) - publicKeyLen;
publicKey = pubKeyBuf;

if (strcmp(keyType, "ecdsa") != 0)
{
Expand All @@ -283,7 +284,7 @@ static int generateKeyPair(BpSAP sap, DtkaDB *db, char *keyType, int keySize)
}

privateKeyLen = keySize;
privateKey = (privKeyBuf + (sizeof privKeyBuf - 1)) - privateKeyLen;
privateKey = privKeyBuf;

sdr_exit_xn(sdr);
#else /* For regression testing only. */
Expand Down
2 changes: 1 addition & 1 deletion tc/dtka/dtkaadmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void managekeyType(int tokenCount, char **tokens)

CHKVOID(sdr_begin_xn(sdr));
sdr_stage(sdr, (char *)&dtkadb, dtkadbObj, sizeof(DtkaDB));
istrcpy(dtkadb.keyType, newkeyType, sizeof(newkeyType));
istrcpy(dtkadb.keyType, newkeyType, sizeof(dtkadb.keyType));
dtkadb.keySize = newkeySize;
sdr_write(sdr, dtkadbObj, (char *)&dtkadb, sizeof(DtkaDB));
if (sdr_end_xn(sdr) < 0)
Expand Down