Jelajahi Sumber

fix scan-build warnings

Steffen Jaeckel 5 tahun lalu
induk
melakukan
cd18fed7ba

+ 4 - 1
src/encauth/ccm/ccm_memory.c

@@ -78,6 +78,9 @@ int ccm_memory(int cipher,
    if (*taglen < 4 || *taglen > 16 || (*taglen % 2) == 1 || headerlen > 0x7fffffffu) {
       return CRYPT_INVALID_ARG;
    }
+   if (noncelen < 7) {
+      return CRYPT_INVALID_ARG;
+   }
 
    /* is there an accelerator? */
    if (cipher_descriptor[cipher].accel_ccm_memory != NULL) {
@@ -144,7 +147,7 @@ int ccm_memory(int cipher,
             (L-1));
 
    /* nonce */
-   for (y = 0; y < 15 - L; y++) {
+   for (y = 0; y < noncelen; y++) {
        PAD[x++] = nonce[y];
    }
 

+ 4 - 2
src/misc/pem/pem_ssh.c

@@ -815,9 +815,11 @@ int ssh_read_authorized_keys_filehandle(FILE *f, ssh_authorized_key_cb cb, void
    LTC_ARGCHK(f != NULL);
    LTC_ARGCHK(cb != NULL);
 
-   fseek(f, 0, SEEK_END);
+   if (fseek(f, 0, SEEK_END) == -1)
+      return CRYPT_ERROR;
    tot_data = ftell(f);
-   rewind(f);
+   if (fseek(f, 0, SEEK_SET) == -1)
+      return CRYPT_ERROR;
    buf = XMALLOC(tot_data);
    if (buf == NULL) {
       return CRYPT_MEM;

+ 2 - 1
src/modes/f8/f8_start.c

@@ -68,7 +68,8 @@ int f8_start(                int  cipher, const unsigned char *IV,
 
    /* encrypt IV */
    if ((err = ecb_encrypt_block(IV, f8->MIV, &f8->ecb)) != CRYPT_OK) {
-      return ecb_done(&f8->ecb);
+      ecb_done(&f8->ecb);
+      return err;
    }
    zeromem(tkey, sizeof(tkey));
    zeromem(f8->IV, sizeof(f8->IV));

+ 1 - 1
src/modes/xts/xts_decrypt.c

@@ -53,7 +53,7 @@ static int s_tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned ch
 int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt, unsigned char *tweak,
                 const symmetric_xts *xts)
 {
-   unsigned char PP[16], CC[16], T[16];
+   unsigned char PP[16] = {0}, CC[16], T[16];
    unsigned long i, m, mo, lim;
    int err;
 

+ 1 - 1
src/modes/xts/xts_encrypt.c

@@ -55,7 +55,7 @@ static int s_tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char
 int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct, unsigned char *tweak,
                 const symmetric_xts *xts)
 {
-   unsigned char PP[16], CC[16], T[16];
+   unsigned char PP[16], CC[16] = {0}, T[16];
    unsigned long i, m, mo, lim;
    int err;