Skip to content

Commit a20c391

Browse files
Merge pull request #10282 from kareem-wolfssl/zd21527
Fix W560 "possible truncation at implicit conversion to type unsigned char" warnings raised by Tasking compiler.
2 parents b9514e7 + c69d969 commit a20c391

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

src/tls13.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8577,7 +8577,10 @@ static WC_INLINE int DecodeTls13SigAlg(byte* input, byte* hashAlgo,
85778577
break;
85788578
#endif
85798579
case NEW_SA_MAJOR:
8580-
*hashAlgo = GetNewSAHashAlgo(input[1]);
8580+
{
8581+
enum wc_MACAlgorithm mac = GetNewSAHashAlgo(input[1]);
8582+
*hashAlgo = (byte)mac;
8583+
}
85818584

85828585
/* PSS encryption: 0x080[4-6] */
85838586
if (input[1] >= RSA_PSS_RSAE_SHA256_MINOR &&

src/wolfio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3286,7 +3286,11 @@ int LwIPNativeSend(WOLFSSL* ssl, char* buf, int sz, void* ctx)
32863286
err_t ret;
32873287
WOLFSSL_LWIP_NATIVE_STATE* nlwip = (WOLFSSL_LWIP_NATIVE_STATE*)ctx;
32883288

3289-
ret = tcp_write(nlwip->pcb, buf, sz, TCP_WRITE_FLAG_COPY);
3289+
if (sz < 0 || sz > (int)WOLFSSL_MAX_16BIT) {
3290+
return BAD_FUNC_ARG;
3291+
}
3292+
3293+
ret = tcp_write(nlwip->pcb, buf, (u16_t)sz, TCP_WRITE_FLAG_COPY);
32903294
if (ret != ERR_OK) {
32913295
sz = WOLFSSL_FATAL_ERROR;
32923296
}

wolfcrypt/src/fe_low_mem.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ void fe_load(byte *x, word32 c)
546546
word32 i;
547547

548548
for (i = 0; i < sizeof(c); i++) {
549-
x[i] = c;
549+
x[i] = (byte)c;
550550
c >>= 8;
551551
}
552552

@@ -636,7 +636,7 @@ void lm_sub(byte* r, const byte* a, const byte* b)
636636
c = 218;
637637
for (i = 0; i + 1 < F25519_SIZE; i++) {
638638
c += 65280 + ((word32)a[i]) - ((word32)b[i]);
639-
r[i] = c;
639+
r[i] = (byte)c;
640640
c >>= 8;
641641
}
642642

@@ -646,7 +646,7 @@ void lm_sub(byte* r, const byte* a, const byte* b)
646646

647647
for (i = 0; i < F25519_SIZE; i++) {
648648
c += r[i];
649-
r[i] = c;
649+
r[i] = (byte)c;
650650
c >>= 8;
651651
}
652652
}
@@ -661,7 +661,7 @@ void lm_neg(byte* r, const byte* a)
661661
c = 218;
662662
for (i = 0; i + 1 < F25519_SIZE; i++) {
663663
c += 65280 - ((word32)a[i]);
664-
r[i] = c;
664+
r[i] = (byte)c;
665665
c >>= 8;
666666
}
667667

@@ -671,7 +671,7 @@ void lm_neg(byte* r, const byte* a)
671671

672672
for (i = 0; i < F25519_SIZE; i++) {
673673
c += r[i];
674-
r[i] = c;
674+
r[i] = (byte)c;
675675
c >>= 8;
676676
}
677677
}
@@ -693,15 +693,15 @@ void fe_mul__distinct(byte *r, const byte *a, const byte *b)
693693
c += ((word32)a[j]) *
694694
((word32)b[i + F25519_SIZE - j]) * 38;
695695

696-
r[i] = c;
696+
r[i] = (byte)c;
697697
}
698698

699699
r[31] &= 127;
700700
c = (c >> 7) * 19;
701701

702702
for (i = 0; i < F25519_SIZE; i++) {
703703
c += r[i];
704-
r[i] = c;
704+
r[i] = (byte)c;
705705
c >>= 8;
706706
}
707707
}
@@ -724,7 +724,7 @@ void fe_mul_c(byte *r, const byte *a, word32 b)
724724
for (i = 0; i < F25519_SIZE; i++) {
725725
c >>= 8;
726726
c += b * ((word32)a[i]);
727-
r[i] = c;
727+
r[i] = (byte)c;
728728
}
729729

730730
r[31] &= 127;
@@ -733,7 +733,7 @@ void fe_mul_c(byte *r, const byte *a, word32 b)
733733

734734
for (i = 0; i < F25519_SIZE; i++) {
735735
c += r[i];
736-
r[i] = c;
736+
r[i] = (byte)c;
737737
c >>= 8;
738738
}
739739
}

0 commit comments

Comments
 (0)