Skip to content

Commit cd18fed

Browse files
committed
fix scan-build warnings
1 parent 3c42b6a commit cd18fed

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

src/encauth/ccm/ccm_memory.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ int ccm_memory(int cipher,
7878
if (*taglen < 4 || *taglen > 16 || (*taglen % 2) == 1 || headerlen > 0x7fffffffu) {
7979
return CRYPT_INVALID_ARG;
8080
}
81+
if (noncelen < 7) {
82+
return CRYPT_INVALID_ARG;
83+
}
8184

8285
/* is there an accelerator? */
8386
if (cipher_descriptor[cipher].accel_ccm_memory != NULL) {
@@ -144,7 +147,7 @@ int ccm_memory(int cipher,
144147
(L-1));
145148

146149
/* nonce */
147-
for (y = 0; y < 15 - L; y++) {
150+
for (y = 0; y < noncelen; y++) {
148151
PAD[x++] = nonce[y];
149152
}
150153

src/misc/pem/pem_ssh.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,9 +815,11 @@ int ssh_read_authorized_keys_filehandle(FILE *f, ssh_authorized_key_cb cb, void
815815
LTC_ARGCHK(f != NULL);
816816
LTC_ARGCHK(cb != NULL);
817817

818-
fseek(f, 0, SEEK_END);
818+
if (fseek(f, 0, SEEK_END) == -1)
819+
return CRYPT_ERROR;
819820
tot_data = ftell(f);
820-
rewind(f);
821+
if (fseek(f, 0, SEEK_SET) == -1)
822+
return CRYPT_ERROR;
821823
buf = XMALLOC(tot_data);
822824
if (buf == NULL) {
823825
return CRYPT_MEM;

src/modes/f8/f8_start.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ int f8_start( int cipher, const unsigned char *IV,
6868

6969
/* encrypt IV */
7070
if ((err = ecb_encrypt_block(IV, f8->MIV, &f8->ecb)) != CRYPT_OK) {
71-
return ecb_done(&f8->ecb);
71+
ecb_done(&f8->ecb);
72+
return err;
7273
}
7374
zeromem(tkey, sizeof(tkey));
7475
zeromem(f8->IV, sizeof(f8->IV));

src/modes/xts/xts_decrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int s_tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned ch
5353
int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt, unsigned char *tweak,
5454
const symmetric_xts *xts)
5555
{
56-
unsigned char PP[16], CC[16], T[16];
56+
unsigned char PP[16] = {0}, CC[16], T[16];
5757
unsigned long i, m, mo, lim;
5858
int err;
5959

src/modes/xts/xts_encrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int s_tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char
5555
int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct, unsigned char *tweak,
5656
const symmetric_xts *xts)
5757
{
58-
unsigned char PP[16], CC[16], T[16];
58+
unsigned char PP[16], CC[16] = {0}, T[16];
5959
unsigned long i, m, mo, lim;
6060
int err;
6161

0 commit comments

Comments
 (0)