Skip to content

Commit b971686

Browse files
committed
Fix some coverity complaints
1 parent ae09808 commit b971686

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

pdfgen.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,8 @@ static void pdf_crypt_pad_password(const char *pwd, uint8_t out[32])
21382138
plen = 32;
21392139
if (pwd && plen > 0)
21402140
memcpy(out, pwd, plen);
2141-
memcpy(out + plen, pdf_crypt_padding, 32 - plen);
2141+
if (plen < 32)
2142+
memcpy(out + plen, pdf_crypt_padding, 32 - plen);
21422143
}
21432144

21442145
/*
@@ -2203,8 +2204,6 @@ static size_t pdf_crypt_object_key(const struct pdf_crypt *crypt,
22032204
uint8_t md5_out[16];
22042205
pdf_md5(key_in, sizeof(key_in), md5_out);
22052206
size_t keylen = PDF_CRYPT_KEY_LEN + 5; /* min(n+5, 16) = 10 for 40-bit */
2206-
if (keylen > 16)
2207-
keylen = 16;
22082207
memcpy(out_key, md5_out, keylen);
22092208
return keylen;
22102209
}

0 commit comments

Comments
 (0)