In all of these cases the cast is safe to do
since we have limits imposed in other ways.
And we want those values as int, so no
alternative to casting.
Change-Id: I3b8dd8d5671e31dba2a23a0a78f36d9dda034b88
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1217
Message-Id: <20251008092859.875-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243794/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -186,11 +186,6 @@ err: |
| 186 | 186 |
return; |
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 |
-#if defined(__GNUC__) || defined(__clang__) |
|
| 190 |
-#pragma GCC diagnostic push |
|
| 191 |
-#pragma GCC diagnostic ignored "-Wconversion" |
|
| 192 |
-#endif |
|
| 193 |
- |
|
| 194 | 189 |
static void |
| 195 | 190 |
openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt) |
| 196 | 191 |
{
|
| ... | ... |
@@ -302,7 +297,7 @@ openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options |
| 302 | 302 |
if (ctx->hmac) |
| 303 | 303 |
{
|
| 304 | 304 |
hmac_ctx_reset(ctx->hmac); |
| 305 |
- hmac_ctx_update(ctx->hmac, hmac_start, BEND(&work) - hmac_start); |
|
| 305 |
+ hmac_ctx_update(ctx->hmac, hmac_start, (int)(BEND(&work) - hmac_start)); |
|
| 306 | 306 |
hmac_ctx_final(ctx->hmac, mac_out); |
| 307 | 307 |
dmsg(D_PACKET_CONTENT, "ENCRYPT HMAC: %s", |
| 308 | 308 |
format_hex(mac_out, hmac_ctx_size(ctx->hmac), 80, &gc)); |
| ... | ... |
@@ -533,7 +528,7 @@ openvpn_decrypt_aead(struct buffer *buf, struct buffer work, struct crypto_optio |
| 533 | 533 |
} |
| 534 | 534 |
} |
| 535 | 535 |
|
| 536 |
- const int ad_size = BPTR(buf) - ad_start; |
|
| 536 |
+ const int ad_size = (int)(BPTR(buf) - ad_start); |
|
| 537 | 537 |
|
| 538 | 538 |
uint8_t *tag_ptr = NULL; |
| 539 | 539 |
int data_len = 0; |
| ... | ... |
@@ -1366,8 +1361,8 @@ read_key_file(struct key2 *key2, const char *file, const unsigned int flags) |
| 1366 | 1366 |
int state = PARSE_INITIAL; |
| 1367 | 1367 |
|
| 1368 | 1368 |
/* constants */ |
| 1369 |
- const int hlen = strlen(static_key_head); |
|
| 1370 |
- const int flen = strlen(static_key_foot); |
|
| 1369 |
+ const int hlen = (int)strlen(static_key_head); |
|
| 1370 |
+ const int flen = (int)strlen(static_key_foot); |
|
| 1371 | 1371 |
const int onekeylen = sizeof(key2->keys[0]); |
| 1372 | 1372 |
|
| 1373 | 1373 |
CLEAR(*key2); |
| ... | ... |
@@ -1378,7 +1373,9 @@ read_key_file(struct key2 *key2, const char *file, const unsigned int flags) |
| 1378 | 1378 |
*/ |
| 1379 | 1379 |
if (flags & RKF_INLINE) /* 'file' is a string containing ascii representation of key */ |
| 1380 | 1380 |
{
|
| 1381 |
- size = strlen(file) + 1; |
|
| 1381 |
+ size_t buf_size = strlen(file) + 1; |
|
| 1382 |
+ ASSERT(buf_size <= INT_MAX); |
|
| 1383 |
+ size = (int)buf_size; |
|
| 1382 | 1384 |
buf_set_read(&in, (const uint8_t *)file, size); |
| 1383 | 1385 |
} |
| 1384 | 1386 |
else /* 'file' is a filename which refers to a file containing the ascii key */ |
| ... | ... |
@@ -1537,10 +1534,6 @@ read_key_file(struct key2 *key2, const char *file, const unsigned int flags) |
| 1537 | 1537 |
gc_free(&gc); |
| 1538 | 1538 |
} |
| 1539 | 1539 |
|
| 1540 |
-#if defined(__GNUC__) || defined(__clang__) |
|
| 1541 |
-#pragma GCC diagnostic pop |
|
| 1542 |
-#endif |
|
| 1543 |
- |
|
| 1544 | 1540 |
int |
| 1545 | 1541 |
write_key_file(const int nkeys, const char *filename) |
| 1546 | 1542 |
{
|