Closed
Bug 1796308
Opened 2 years ago
Closed 2 years ago
-Wtautological-constant-out-of-range-compare and -Wtype-limits warnings in NSS
Categories
(NSS :: Libraries, defect)
NSS
Libraries
Tracking
(Not tracked)
RESOLVED
FIXED
3.85
People
(Reporter: glandium, Assigned: glandium)
References
Details
Attachments
(1 file)
Lumping them together because although they are from different compilers on different portions of the code, they are rooted in the same-ish pattern and call for similar fixes/workarounds.
On Linux builds with GCC:
[task 2022-10-19T21:14:58.041Z] 21:14:58 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c:218:15: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:14:58.041Z] 21:14:58 INFO - inlen >= ((1ULL << 32) - 2) * AES_BLOCK_SIZE) {
[task 2022-10-19T21:14:58.041Z] 21:14:58 INFO - ^~
[task 2022-10-19T21:14:58.041Z] 21:14:58 INFO - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c: In function 'intel_AES_GCM_DecryptUpdate':
[task 2022-10-19T21:14:58.042Z] 21:14:58 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c:293:15: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:14:58.042Z] 21:14:58 INFO - inlen >= ((1ULL << 32) - 2) * AES_BLOCK_SIZE) {
[task 2022-10-19T21:14:58.042Z] 21:14:58 INFO - ^~
[task 2022-10-19T21:14:58.043Z] 21:14:58 INFO - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c: In function 'intel_AES_GCM_EncryptAEAD':
[task 2022-10-19T21:14:58.043Z] 21:14:58 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c:349:15: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:14:58.044Z] 21:14:58 INFO - inlen >= ((1ULL << 32) - 2) * AES_BLOCK_SIZE) {
[task 2022-10-19T21:14:58.044Z] 21:14:58 INFO - ^~
[task 2022-10-19T21:14:58.044Z] 21:14:58 INFO - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c: In function 'intel_AES_GCM_DecryptAEAD':
[task 2022-10-19T21:14:58.044Z] 21:14:58 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/intel-gcm-wrap.c:430:15: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:14:58.044Z] 21:14:58 INFO - inlen >= ((1ULL << 32) - 2) * AES_BLOCK_SIZE) {
[task 2022-10-19T21:14:58.044Z] 21:14:58 INFO - ^~
[task 2022-10-19T21:14:58.044Z] 21:14:58 INFO - cc1: all warnings being treated as errors
[task 2022-10-19T21:15:11.155Z] 21:15:11 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c:241:32: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:15:11.155Z] 21:15:11 INFO - if (sizeof(len) > 4 && len >= (1ULL << (6 + 32))) {
[task 2022-10-19T21:15:11.156Z] 21:15:11 INFO - ^~
[task 2022-10-19T21:15:11.156Z] 21:15:11 INFO - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c: In function 'ChaCha20Poly1305_Seal':
[task 2022-10-19T21:15:11.156Z] 21:15:11 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c:267:42: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:15:11.156Z] 21:15:11 INFO - if (sizeof(inputLen) > 4 && inputLen >= (1ULL << (6 + 32))) {
[task 2022-10-19T21:15:11.157Z] 21:15:11 INFO - ^~
[task 2022-10-19T21:15:11.157Z] 21:15:11 INFO - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c: In function 'ChaCha20Poly1305_Encrypt':
[task 2022-10-19T21:15:11.157Z] 21:15:11 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c:404:42: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:15:11.157Z] 21:15:11 INFO - if (sizeof(inputLen) > 4 && inputLen >= (1ULL << (6 + 32))) {
[task 2022-10-19T21:15:11.158Z] 21:15:11 INFO - ^~
[task 2022-10-19T21:15:11.158Z] 21:15:11 INFO - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c: In function 'ChaCha20Poly1305_Decrypt':
[task 2022-10-19T21:15:11.158Z] 21:15:11 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/chacha20poly1305.c:461:42: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:15:11.159Z] 21:15:11 INFO - if (sizeof(inputLen) > 4 && inputLen >= (1ULL << (6 + 32))) {
[task 2022-10-19T21:15:11.159Z] 21:15:11 INFO - ^~
[task 2022-10-19T21:15:11.159Z] 21:15:11 INFO - cc1: all warnings being treated as errors
On Windows builds:
[task 2022-10-19T21:16:55.484Z] 21:16:55 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/pqg.c(345,16): error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned long' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
[task 2022-10-19T21:16:55.485Z] 21:16:55 INFO - if (addend < MP_DIGIT_MAX) {
[task 2022-10-19T21:16:55.485Z] 21:16:55 INFO - ~~~~~~ ^ ~~~~~~~~~~~~
[task 2022-10-19T21:16:55.485Z] 21:16:55 INFO - 1 error generated.
Assignee | ||
Comment 1•2 years ago
|
||
Also:
[task 2022-10-19T21:16:10.769Z] 21:16:10 ERROR - /builds/worker/checkouts/gecko/security/nss/lib/freebl/gcm.c:494:39: error: comparison is always false due to limited range of data type [-Werror=type-limits]
[task 2022-10-19T21:16:10.769Z] 21:16:10 INFO - if (sizeof(AADLen) >= 8 && AADLen > (1ULL << 61) - 1) {
[task 2022-10-19T21:16:10.769Z] 21:16:10 INFO - ^
[task 2022-10-19T21:16:10.769Z] 21:16:10 INFO - cc1: all warnings being treated as errors
Assignee | ||
Comment 2•2 years ago
|
||
Unfortunately, e.g. ((unsigned long long)len) >= (1ULL << (6 + 32))
doesn't work around the warning, and while
len >= (unsigned int)(1ULL << (6 + 32))
would, it feels dangerous. The
ideal would be casting to typeof(len), but it's not standard.
Assignee | ||
Comment 3•2 years ago
|
||
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.85
You need to log in
before you can comment on or make changes to this bug.
Description
•