Skip to content

Commit 10ca3a0

Browse files
olszomalmtrojnar
authored andcommitted
Suppress compiler warnings
1 parent 9ea7e85 commit 10ca3a0

File tree

7 files changed

+174
-1
lines changed

7 files changed

+174
-1
lines changed

appx.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,18 @@ static uint8_t *appx_calc_zip_central_directory_hash(ZIP_FILE *zip, const EVP_MD
873873
u_char *mdbuf = NULL;
874874
BIO *bhash = BIO_new(BIO_f_md());
875875

876+
#if defined(__GNUC__)
877+
#pragma GCC diagnostic push
878+
#pragma GCC diagnostic ignored "-Wcast-qual"
879+
#endif
876880
if (!BIO_set_md(bhash, md)) {
877881
fprintf(stderr, "Unable to set the message digest of BIO\n");
878882
BIO_free_all(bhash);
879883
return NULL; /* FAILED */
880884
}
885+
#if defined(__GNUC__)
886+
#pragma GCC diagnostic pop
887+
#endif
881888
BIO_push(bhash, BIO_new(BIO_s_null()));
882889
if (!appx_write_central_directory(bhash, zip, 1, cdOffset)) {
883890
fprintf(stderr, "Unable to write central directory\n");
@@ -1000,11 +1007,18 @@ static uint8_t *appx_calc_zip_data_hash(uint64_t *cdOffset, ZIP_FILE *zip, const
10001007
BIO *bhash = BIO_new(BIO_f_md());
10011008
uint64_t noEntries = 0;
10021009

1010+
#if defined(__GNUC__)
1011+
#pragma GCC diagnostic push
1012+
#pragma GCC diagnostic ignored "-Wcast-qual"
1013+
#endif
10031014
if (!BIO_set_md(bhash, md)) {
10041015
fprintf(stderr, "Unable to set the message digest of BIO\n");
10051016
BIO_free_all(bhash);
10061017
return NULL; /* FAILED */
10071018
}
1019+
#if defined(__GNUC__)
1020+
#pragma GCC diagnostic pop
1021+
#endif
10081022
BIO_push(bhash, BIO_new(BIO_s_null()));
10091023
*cdOffset = 0;
10101024
for (entry = zip->centralDirectoryHead; entry != NULL; entry = entry->next) {
@@ -1758,12 +1772,19 @@ static u_char *zipCalcDigest(ZIP_FILE *zip, const char *fileName, const EVP_MD *
17581772
return NULL; /* FAILED */
17591773
}
17601774
bhash = BIO_new(BIO_f_md());
1775+
#if defined(__GNUC__)
1776+
#pragma GCC diagnostic push
1777+
#pragma GCC diagnostic ignored "-Wcast-qual"
1778+
#endif
17611779
if (!BIO_set_md(bhash, md)) {
17621780
fprintf(stderr, "Unable to set the message digest of BIO\n");
17631781
OPENSSL_free(data);
17641782
BIO_free_all(bhash);
17651783
return NULL; /* FAILED */
17661784
}
1785+
#if defined(__GNUC__)
1786+
#pragma GCC diagnostic pop
1787+
#endif
17671788
BIO_push(bhash, BIO_new(BIO_s_null()));
17681789
if (!bio_hash_data(bhash, (char *)data, 0, dataSize)) {
17691790
OPENSSL_free(data);

cab.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,18 @@ static u_char *cab_digest_calc(FILE_FORMAT_CTX *ctx, const EVP_MD *md)
205205
u_char *mdbuf = NULL;
206206
BIO *bhash = BIO_new(BIO_f_md());
207207

208+
#if defined(__GNUC__)
209+
#pragma GCC diagnostic push
210+
#pragma GCC diagnostic ignored "-Wcast-qual"
211+
#endif
208212
if (!BIO_set_md(bhash, md)) {
209213
fprintf(stderr, "Unable to set the message digest of BIO\n");
210214
BIO_free_all(bhash);
211215
return 0; /* FAILED */
212216
}
217+
#if defined(__GNUC__)
218+
#pragma GCC diagnostic pop
219+
#endif
213220
BIO_push(bhash, BIO_new(BIO_s_null()));
214221

215222
/* u1 signature[4] 4643534D MSCF: 0-3 */

helpers.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,13 +777,29 @@ static int X509_compare(const X509 *const *a, const X509 *const *b)
777777
size_t a_len, b_len;
778778
int ret;
779779

780+
#if OPENSSL_VERSION_NUMBER<0x30000000L
781+
#if defined(__clang__)
782+
#pragma clang diagnostic push
783+
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
784+
#elif defined(__GNUC__)
785+
#pragma GCC diagnostic push
786+
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
787+
#endif
788+
#endif /* OPENSSL_VERSION_NUMBER<0x30000000L */
780789
a_len = (size_t)i2d_X509(*a, NULL);
781790
a_tmp = a_data = OPENSSL_malloc(a_len);
782791
i2d_X509(*a, &a_tmp);
783792

784793
b_len = (size_t)i2d_X509(*b, NULL);
785794
b_tmp = b_data = OPENSSL_malloc(b_len);
786795
i2d_X509(*b, &b_tmp);
796+
#if OPENSSL_VERSION_NUMBER<0x30000000L
797+
#if defined(__clang__)
798+
#pragma clang diagnostic pop
799+
#elif defined(__GNUC__)
800+
#pragma GCC diagnostic pop
801+
#endif
802+
#endif /* OPENSSL_VERSION_NUMBER<0x30000000L */
787803

788804
ret = memcmp(a_data, b_data, MIN(a_len, b_len));
789805
OPENSSL_free(a_data);

msi.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,18 @@ static u_char *msi_digest_calc(FILE_FORMAT_CTX *ctx, const EVP_MD *md)
373373
u_char *mdbuf = NULL;
374374
BIO *bhash = BIO_new(BIO_f_md());
375375

376+
#if defined(__GNUC__)
377+
#pragma GCC diagnostic push
378+
#pragma GCC diagnostic ignored "-Wcast-qual"
379+
#endif
376380
if (!BIO_set_md(bhash, md)) {
377381
fprintf(stderr, "Unable to set the message digest of BIO\n");
378382
BIO_free_all(bhash);
379383
return NULL; /* FAILED */
380384
}
385+
#if defined(__GNUC__)
386+
#pragma GCC diagnostic pop
387+
#endif
381388
BIO_push(bhash, BIO_new(BIO_s_null()));
382389
if (!bio_hash_data(bhash, ctx->options->indata, 0, ctx->msi_ctx->fileend)) {
383390
fprintf(stderr, "Unable to calculate digest\n");
@@ -426,11 +433,18 @@ static int msi_verify_digests(FILE_FORMAT_CTX *ctx, PKCS7 *p7)
426433
printf("Message digest algorithm : %s\n", OBJ_nid2sn(mdtype));
427434
md = EVP_get_digestbynid(mdtype);
428435
hash = BIO_new(BIO_f_md());
436+
#if defined(__GNUC__)
437+
#pragma GCC diagnostic push
438+
#pragma GCC diagnostic ignored "-Wcast-qual"
439+
#endif
429440
if (!BIO_set_md(hash, md)) {
430441
fprintf(stderr, "Unable to set the message digest of BIO\n");
431442
BIO_free_all(hash);
432443
return 0; /* FAILED */
433444
}
445+
#if defined(__GNUC__)
446+
#pragma GCC diagnostic pop
447+
#endif
434448
BIO_push(hash, BIO_new(BIO_s_null()));
435449
if (ctx->msi_ctx->p_msiex) {
436450
BIO *prehash = BIO_new(BIO_f_md());
@@ -440,12 +454,19 @@ static int msi_verify_digests(FILE_FORMAT_CTX *ctx, PKCS7 *p7)
440454
BIO_free_all(prehash);
441455
return 0; /* FAILED */
442456
}
457+
#if defined(__GNUC__)
458+
#pragma GCC diagnostic push
459+
#pragma GCC diagnostic ignored "-Wcast-qual"
460+
#endif
443461
if (!BIO_set_md(prehash, md)) {
444462
fprintf(stderr, "Unable to set the message digest of BIO\n");
445463
BIO_free_all(hash);
446464
BIO_free_all(prehash);
447465
return 0; /* FAILED */
448466
}
467+
#if defined(__GNUC__)
468+
#pragma GCC diagnostic pop
469+
#endif
449470
BIO_push(prehash, BIO_new(BIO_s_null()));
450471

451472
print_hash("Current MsiDigitalSignatureEx ", "", (u_char *)ctx->msi_ctx->p_msiex,
@@ -2298,11 +2319,18 @@ static int msi_calc_MsiDigitalSignatureEx(FILE_FORMAT_CTX *ctx, BIO *hash)
22982319
size_t written;
22992320
BIO *prehash = BIO_new(BIO_f_md());
23002321

2322+
#if defined(__GNUC__)
2323+
#pragma GCC diagnostic push
2324+
#pragma GCC diagnostic ignored "-Wcast-qual"
2325+
#endif
23012326
if (!BIO_set_md(prehash, ctx->options->md)) {
23022327
fprintf(stderr, "Unable to set the message digest of BIO\n");
23032328
BIO_free_all(prehash);
23042329
return 0; /* FAILED */
23052330
}
2331+
#if defined(__GNUC__)
2332+
#pragma GCC diagnostic pop
2333+
#endif
23062334
BIO_push(prehash, BIO_new(BIO_s_null()));
23072335

23082336
if (!msi_prehash_dir(ctx->msi_ctx->dirent, prehash, 1)) {

osslsigncode.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,17 @@ static BIO *bio_encode_rfc3161_request(PKCS7 *p7, const EVP_MD *md)
303303
goto out;
304304

305305
bhash = BIO_new(BIO_f_md());
306+
#if defined(__GNUC__)
307+
#pragma GCC diagnostic push
308+
#pragma GCC diagnostic ignored "-Wcast-qual"
309+
#endif
306310
if (!BIO_set_md(bhash, md)) {
307311
fprintf(stderr, "Unable to set the message digest of BIO\n");
308312
goto out;
309313
}
314+
#if defined(__GNUC__)
315+
#pragma GCC diagnostic pop
316+
#endif
310317
BIO_push(bhash, BIO_new(BIO_s_null()));
311318
BIO_write(bhash, si->enc_digest->data, si->enc_digest->length);
312319
BIO_gets(bhash, (char*)mdbuf, EVP_MD_size(md));
@@ -1817,10 +1824,17 @@ static int trusted_cert(X509 *cert, int error) {
18171824
const EVP_MD *md = EVP_get_digestbynid(NID_sha256);
18181825
BIO *bhash = BIO_new(BIO_f_md());
18191826

1827+
#if defined(__GNUC__)
1828+
#pragma GCC diagnostic push
1829+
#pragma GCC diagnostic ignored "-Wcast-qual"
1830+
#endif
18201831
if (!BIO_set_md(bhash, md)) {
18211832
BIO_free_all(bhash);
18221833
return 0; /* FAILED */
18231834
}
1835+
#if defined(__GNUC__)
1836+
#pragma GCC diagnostic pop
1837+
#endif
18241838
BIO_push(bhash, BIO_new(BIO_s_null()));
18251839
len = i2d_X509(cert, NULL);
18261840
p = OPENSSL_malloc((size_t)len);
@@ -2173,12 +2187,19 @@ static int verify_timestamp_token(PKCS7 *p7, CMS_ContentInfo *timestamp)
21732187

21742188
/* compute a hash from the encrypted message digest value of the file */
21752189
bhash = BIO_new(BIO_f_md());
2190+
#if defined(__GNUC__)
2191+
#pragma GCC diagnostic push
2192+
#pragma GCC diagnostic ignored "-Wcast-qual"
2193+
#endif
21762194
if (!BIO_set_md(bhash, md)) {
21772195
fprintf(stderr, "Unable to set the message digest of BIO\n");
21782196
BIO_free_all(bhash);
21792197
TS_TST_INFO_free(token);
21802198
return 0; /* FAILED */
21812199
}
2200+
#if defined(__GNUC__)
2201+
#pragma GCC diagnostic pop
2202+
#endif
21822203
BIO_push(bhash, BIO_new(BIO_s_null()));
21832204
BIO_write(bhash, si->enc_digest->data, si->enc_digest->length);
21842205
BIO_gets(bhash, (char*)mdbuf, EVP_MD_size(md));
@@ -2531,12 +2552,19 @@ static int verify_leaf_hash(X509 *cert, const char *leafhash)
25312552

25322553
/* compute the leaf certificate hash */
25332554
bhash = BIO_new(BIO_f_md());
2555+
#if defined(__GNUC__)
2556+
#pragma GCC diagnostic push
2557+
#pragma GCC diagnostic ignored "-Wcast-qual"
2558+
#endif
25342559
if (!BIO_set_md(bhash, md)) {
25352560
fprintf(stderr, "Unable to set the message digest of BIO\n");
25362561
BIO_free_all(bhash);
25372562
OPENSSL_free(mdbuf);
25382563
return 0; /* FAILED */
25392564
}
2565+
#if defined(__GNUC__)
2566+
#pragma GCC diagnostic pop
2567+
#endif
25402568
BIO_push(bhash, BIO_new(BIO_s_null()));
25412569
certlen = (size_t)i2d_X509(cert, NULL);
25422570
certbuf = OPENSSL_malloc(certlen);
@@ -3346,7 +3374,23 @@ static int PKCS7_compare(const PKCS7 *const *a, const PKCS7 *const *b)
33463374
long index_a, index_b;
33473375
int ret = 0;
33483376

3377+
#if OPENSSL_VERSION_NUMBER<0x30000000L
3378+
#if defined(__clang__)
3379+
#pragma clang diagnostic push
3380+
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
3381+
#elif defined(__GNUC__)
3382+
#pragma GCC diagnostic push
3383+
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
3384+
#endif
3385+
#endif /* OPENSSL_VERSION_NUMBER<0x30000000L */
33493386
p7_a = PKCS7_dup(*a);
3387+
#if OPENSSL_VERSION_NUMBER<0x30000000L
3388+
#if defined(__clang__)
3389+
#pragma clang diagnostic pop
3390+
#elif defined(__GNUC__)
3391+
#pragma GCC diagnostic pop
3392+
#endif
3393+
#endif /* OPENSSL_VERSION_NUMBER>=0x30000000L */
33503394
if (!p7_a)
33513395
goto out;
33523396
signer_info = PKCS7_get_signer_info(p7_a);
@@ -3358,7 +3402,23 @@ static int PKCS7_compare(const PKCS7 *const *a, const PKCS7 *const *b)
33583402
time_a = asn1_time_get_si_time(si);
33593403
index_a = get_sequence_number(si);
33603404

3405+
#if OPENSSL_VERSION_NUMBER<0x30000000L
3406+
#if defined(__clang__)
3407+
#pragma clang diagnostic push
3408+
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
3409+
#elif defined(__GNUC__)
3410+
#pragma GCC diagnostic push
3411+
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
3412+
#endif
3413+
#endif /* OPENSSL_VERSION_NUMBER<0x30000000L */
33613414
p7_b = PKCS7_dup(*b);
3415+
#if OPENSSL_VERSION_NUMBER<0x30000000L
3416+
#if defined(__clang__)
3417+
#pragma clang diagnostic pop
3418+
#elif defined(__GNUC__)
3419+
#pragma GCC diagnostic pop
3420+
#endif
3421+
#endif /* OPENSSL_VERSION_NUMBER>=0x30000000L */
33623422
if (!p7_b)
33633423
goto out;
33643424
signer_info = PKCS7_get_signer_info(p7_b);
@@ -5011,9 +5071,16 @@ int main(int argc, char **argv)
50115071
if (options.cmd != CMD_VERIFY) {
50125072
/* Create message digest BIO */
50135073
hash = BIO_new(BIO_f_md());
5074+
#if defined(__GNUC__)
5075+
#pragma GCC diagnostic push
5076+
#pragma GCC diagnostic ignored "-Wcast-qual"
5077+
#endif
50145078
if (!BIO_set_md(hash, options.md)) {
50155079
DO_EXIT_0("Unable to set the message digest of BIO\n");
50165080
}
5081+
#if defined(__GNUC__)
5082+
#pragma GCC diagnostic pop
5083+
#endif
50175084
/* Create outdata file */
50185085
outdata = BIO_new_file(options.outfile, "w+bx");
50195086
if (!outdata && errno != EEXIST)

pe.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,18 @@ static BIO *pe_digest_calc_bio(FILE_FORMAT_CTX *ctx, const EVP_MD *md)
779779
uint32_t idx = 0, fileend;
780780
BIO *bhash = BIO_new(BIO_f_md());
781781

782+
#if defined(__GNUC__)
783+
#pragma GCC diagnostic push
784+
#pragma GCC diagnostic ignored "-Wcast-qual"
785+
#endif
782786
if (!BIO_set_md(bhash, md)) {
783787
fprintf(stderr, "Unable to set the message digest of BIO\n");
784788
BIO_free_all(bhash);
785789
return 0; /* FAILED */
786790
}
791+
#if defined(__GNUC__)
792+
#pragma GCC diagnostic pop
793+
#endif
787794
BIO_push(bhash, BIO_new(BIO_s_null()));
788795
if (ctx->pe_ctx->sigpos)
789796
fileend = ctx->pe_ctx->sigpos;
@@ -958,11 +965,18 @@ static u_char *pe_page_hash_calc(int *rphlen, FILE_FORMAT_CTX *ctx, int phtype)
958965
phlen = pphlen * (3 + (int)nsections + (int)(ctx->pe_ctx->fileend / pagesize));
959966

960967
bhash = BIO_new(BIO_f_md());
968+
#if defined(__GNUC__)
969+
#pragma GCC diagnostic push
970+
#pragma GCC diagnostic ignored "-Wcast-qual"
971+
#endif
961972
if (!BIO_set_md(bhash, md)) {
962973
fprintf(stderr, "Unable to set the message digest of BIO\n");
963974
BIO_free_all(bhash);
964975
return NULL; /* FAILED */
965976
}
977+
#if defined(__GNUC__)
978+
#pragma GCC diagnostic pop
979+
#endif
966980
BIO_push(bhash, BIO_new(BIO_s_null()));
967981
if (!BIO_write_ex(bhash, ctx->options->indata, ctx->pe_ctx->header_size + 88, &written)
968982
|| written != ctx->pe_ctx->header_size + 88) {
@@ -1005,13 +1019,20 @@ static u_char *pe_page_hash_calc(int *rphlen, FILE_FORMAT_CTX *ctx, int phtype)
10051019
for (l=0; l<rs; l+=pagesize, pi++) {
10061020
PUT_UINT32_LE(ro + l, res + pi*pphlen);
10071021
bhash = BIO_new(BIO_f_md());
1022+
#if defined(__GNUC__)
1023+
#pragma GCC diagnostic push
1024+
#pragma GCC diagnostic ignored "-Wcast-qual"
1025+
#endif
10081026
if (!BIO_set_md(bhash, md)) {
10091027
fprintf(stderr, "Unable to set the message digest of BIO\n");
10101028
BIO_free_all(bhash);
10111029
OPENSSL_free(zeroes);
10121030
OPENSSL_free(res);
10131031
return NULL; /* FAILED */
10141032
}
1033+
#if defined(__GNUC__)
1034+
#pragma GCC diagnostic pop
1035+
#endif
10151036
BIO_push(bhash, BIO_new(BIO_s_null()));
10161037
if (rs - l < pagesize) {
10171038
if (!BIO_write_ex(bhash, ctx->options->indata + ro + l, rs - l, &written)

0 commit comments

Comments
 (0)