Skip to content

Commit a6257ca

Browse files
Merge pull request #6724 from julek-wolfssl/zd/16445
ZD16445
2 parents 5f44a73 + b771b6e commit a6257ca

4 files changed

Lines changed: 40 additions & 14 deletions

File tree

tests/api.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,7 +3728,7 @@ static int test_wolfSSL_CTX_load_verify_buffer_ex(void)
37283728
WOLFSSL_CTX* ctx;
37293729
const char* ca_expired_cert_file = "./certs/test/expired/expired-ca.der";
37303730
byte ca_expired_cert[TWOK_BUF];
3731-
word32 sizeof_ca_expired_cert;
3731+
word32 sizeof_ca_expired_cert = 0;
37323732
XFILE fp = XBADFILE;
37333733

37343734
#ifndef NO_WOLFSSL_CLIENT
@@ -11337,7 +11337,7 @@ static int test_wolfSSL_no_password_cb(void)
1133711337
const char eccPkcs8PrivKeyDerFile[] = "./certs/ecc-privkeyPkcs8.der";
1133811338
const char eccPkcs8PrivKeyPemFile[] = "./certs/ecc-privkeyPkcs8.pem";
1133911339
XFILE f = XBADFILE;
11340-
int bytes;
11340+
int bytes = 0;
1134111341

1134211342
#ifndef NO_WOLFSSL_CLIENT
1134311343
ExpectNotNull(ctx = wolfSSL_CTX_new(wolfTLS_client_method()));
@@ -19788,7 +19788,7 @@ static int test_wc_DsaKeyToPublicDer(void)
1978819788
DsaKey key;
1978919789
WC_RNG rng;
1979019790
byte* der = NULL;
19791-
word32 sz;
19791+
word32 sz = 0;
1979219792
word32 idx = 0;
1979319793

1979419794
XMEMSET(&key, 0, sizeof(DsaKey));
@@ -26174,7 +26174,7 @@ static int test_wc_PKCS7_EncodeDecodeEnvelopedData(void)
2617426174
#if !defined(NO_AES) && defined(HAVE_AES_CBC) && !defined(NO_AES_256)
2617526175
/* test of decrypt callback with KEKRI enveloped data */
2617626176
{
26177-
int envelopedSz;
26177+
int envelopedSz = 0;
2617826178
const byte keyId[] = { 0x00 };
2617926179

2618026180
ExpectNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId));
@@ -26699,7 +26699,7 @@ static int test_wc_PKCS7_BER(void)
2669926699
#ifndef NO_DES3
2670026700
byte decoded[2048];
2670126701
#endif
26702-
word32 derSz;
26702+
word32 derSz = 0;
2670326703

2670426704
ExpectTrue((f = XFOPEN(fName, "rb")) != XBADFILE);
2670526705
ExpectTrue((derSz = (word32)XFREAD(der, 1, sizeof(der), f)) > 0);

tests/w64wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int w64wrapper_test(void)
4141

4242
a = w64From32(0x01020304, 0x05060708);
4343
#if defined(WORD64_AVAILABLE) && !defined(WOLFSSL_W64_WRAPPER_TEST)
44-
if (a.n != 0x0102030405060708)
44+
if (a.n != 0x0102030405060708LL)
4545
return -1;
4646
#else
4747
if (a.n[0] != 0x01020304 || a.n[1] != 0x05060708)

wolfcrypt/src/asn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,13 @@ static word32 SizeASN_Num(word32 n, int bits, byte tag)
639639
* @param [in] idx Index of item working on.
640640
*/
641641
static void SizeASN_CalcDataLength(const ASNItem* asn, ASNSetData *data,
642-
int idx, int max)
642+
int idx, int maxIdx)
643643
{
644644
int j;
645645

646646
data[idx].data.buffer.length = 0;
647647
/* Sum the item length of all items underneath. */
648-
for (j = idx + 1; j < max; j++) {
648+
for (j = idx + 1; j < maxIdx; j++) {
649649
/* Stop looking if the next ASN.1 is same level or higher. */
650650
if (asn[j].depth <= asn[idx].depth)
651651
break;

wolfcrypt/src/misc.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,41 @@ WC_MISC_STATIC WC_INLINE void xorbufout(void* out, const void* buf,
273273
{
274274
word32 i;
275275
byte* o;
276-
byte* b;
276+
const byte* b;
277277
const byte* m;
278278

279279
o = (byte*)out;
280-
b = (byte*)buf;
280+
b = (const byte*)buf;
281281
m = (const byte*)mask;
282282

283283

284284
if (((wc_ptr_t)o) % WOLFSSL_WORD_SIZE ==
285285
((wc_ptr_t)b) % WOLFSSL_WORD_SIZE &&
286286
((wc_ptr_t)b) % WOLFSSL_WORD_SIZE ==
287287
((wc_ptr_t)m) % WOLFSSL_WORD_SIZE) {
288+
/* type-punning helpers */
289+
union {
290+
byte* bp;
291+
wolfssl_word* wp;
292+
} tpo;
293+
union {
294+
const byte* bp;
295+
const wolfssl_word* wp;
296+
} tpb, tpm;
288297
/* Alignment checks out. Possible to XOR words. */
289298
/* Move alignment so that it lines up with a
290299
* WOLFSSL_WORD_SIZE boundary */
291300
while (((wc_ptr_t)b) % WOLFSSL_WORD_SIZE != 0 && count > 0) {
292301
*(o++) = (byte)(*(b++) ^ *(m++));
293302
count--;
294303
}
295-
XorWordsOut( (wolfssl_word**)&o, (const wolfssl_word**)&b,
296-
(const wolfssl_word**)&m, count / WOLFSSL_WORD_SIZE);
304+
tpo.bp = o;
305+
tpb.bp = b;
306+
tpm.bp = m;
307+
XorWordsOut( &tpo.wp, &tpb.wp, &tpm.wp, count / WOLFSSL_WORD_SIZE);
308+
o = tpo.bp;
309+
b = tpb.bp;
310+
m = tpm.bp;
297311
count %= WOLFSSL_WORD_SIZE;
298312
}
299313

@@ -326,15 +340,27 @@ WC_MISC_STATIC WC_INLINE void xorbuf(void* buf, const void* mask, word32 count)
326340

327341
if (((wc_ptr_t)b) % WOLFSSL_WORD_SIZE ==
328342
((wc_ptr_t)m) % WOLFSSL_WORD_SIZE) {
343+
/* type-punning helpers */
344+
union {
345+
byte* bp;
346+
wolfssl_word* wp;
347+
} tpb;
348+
union {
349+
const byte* bp;
350+
const wolfssl_word* wp;
351+
} tpm;
329352
/* Alignment checks out. Possible to XOR words. */
330353
/* Move alignment so that it lines up with a
331354
* WOLFSSL_WORD_SIZE boundary */
332355
while (((wc_ptr_t)buf) % WOLFSSL_WORD_SIZE != 0 && count > 0) {
333356
*(b++) ^= *(m++);
334357
count--;
335358
}
336-
XorWords( (wolfssl_word**)&b,
337-
(const wolfssl_word**)&m, count / WOLFSSL_WORD_SIZE);
359+
tpb.bp = b;
360+
tpm.bp = m;
361+
XorWords( &tpb.wp, &tpm.wp, count / WOLFSSL_WORD_SIZE);
362+
b = tpb.bp;
363+
m = tpm.bp;
338364
count %= WOLFSSL_WORD_SIZE;
339365
}
340366

0 commit comments

Comments
 (0)