Repository navigation
Conversation
Closes networkupstools#676 Signed-off-by: Arnaud Quette <ArnaudQuette@eaton.com>
zykh
left a comment
There was a problem hiding this comment.
As previously mentioned, I still think that we should also make maxage, and friends, unsigned int.
Signed-off-by: Arnaud Quette <ArnaudQuette@eaton.com>
Signed-off-by: Arnaud Quette <ArnaudQuette@eaton.com>
|
@zykh fixed the both |
zykh
left a comment
There was a problem hiding this comment.
Just a couple of things:
- printf formats:
Lines 699 to 702 in 3d79006
- shouldn't the following be
if (certrequest < NETSSL_CERTREQ_NO || certrequest > NETSSL_CERTREQ_REQUIRE)(or, given that nowcertrequestis unsigned andNETSSL_CERTREQ_NOis zero, justif (certrequest > NETSSL_CERTREQ_REQUIRE)) ?
(i.e.||instead of&&, andNETSSL_CERTREQ_REQUIRE, which is 2, instead ofNETSSL_CERTREQ_REQUEST, which is 1)
Lines 481 to 485 in 3d79006
- how unlikely is that
sysconf(_SC_OPEN_MAX)returns a)-1or b) a value that (aslong) exceeds what can be stored in anunsigned int?
here:
Line 696 in 3d79006
and here:
Line 1251 in 3d79006
Updated over recent changes on the master branch, including PR networkupstools#3631. Compared to it: * Use same C formatting strings for invalid values as much as possible, so the compiler has easier time with optimizing the copies away * Convert `maxage` and `tracking_delay` to `unsigned int`, as proposed in this PR originally * Range-check `CERTREQUEST` setting * Adapt `test_upsdconf.c` to new data types Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…pstools#3631] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…upstools#3631] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…etworkupstools#3631, networkupstools#677] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
e45c68c to
b79b8cb
Compare
…he test runner [networkupstools#677, networkupstools#3631] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
12a5b64 to
b79b8cb
Compare
|
@user01010111 : wanna take a bite at another low-hanging fruit? It seems we have some trouble with 32-bit builds here, probably related to change of these data points into My recent commits on the branch fixed same issues for default (64-bit here) builds. Going offline now, so if you (or your AI) has a moment to comment here with a suggested fix, that would be welcome :)
|
|
Suggested test-only follow-up for The six failures come from the test still treating Enabling NSS client validation exposed another outdated part of the same test: its CERTREQUEST stub was still signed, and its expectations allowed values above the parser's new 0..2 limit. The patch aligns those test expectations with the current parser. It changes only I reproduced the six failures on the unchanged head, then ran the corrected test natively on i386 and x86-64: 263 checks passed on each. The NSS client-validation configuration passed 365 checks. Both default builds, all 13 tests in the x86-64 test directory, and the whitespace/non-ASCII checks passed. Top-level AI assistance: OpenAI Codex, using gpt-5.6-sol for initial scoping and gpt-6-astra for review, implementation and validation. I have reviewed this change and accept responsibility for contributing it under the project's licence. Patch against b79b8cb--- a/tests/test_upsdconf.c
+++ b/tests/test_upsdconf.c
@@ -24,7 +24,7 @@
char *certfile = NULL, *certpath = NULL, *certname = NULL, *certpasswd = NULL;
int disable_weak_ssl = 0;
#ifdef WITH_CLIENT_CERTIFICATE_VALIDATION
-int certrequest = 0;
+unsigned int certrequest = 0;
#endif
/* These daemon operations must not be reached by the configuration tests. */
@@ -185,23 +185,25 @@
sizeof(int), sizeof(long), sizeof(nfds_t));
for (i = 0; i < sizeof(options) / sizeof(options[0]); i++) {
previous = !strcmp(options[i], "CERTREQUEST") ? 2 : 17;
- check_value(options[i], "0", 1, 0);
- check_value(options[i], "1", 1, 1);
- check_value(options[i], "2", 1, 2);
- check_value(options[i], "00015", 1, 15);
- check_value(options[i], "32 \t", 1, 32);
- check_value(options[i], "3600", 1, 3600);
- for (j = 0; j < sizeof(invalid) / sizeof(invalid[0]); j++)
- check_value(options[i], invalid[j], 0, previous);
-
- limit = (uintmax_t)INT_MAX;
+ limit = (uintmax_t)NETSSL_CERTREQ_MAX;
if (!strcmp(options[i], "MAXAGE") || !strcmp(options[i], "TRACKINGDELAY")) {
limit = (uintmax_t)UINT_MAX;
} else
if (!strcmp(options[i], "MAXCONN")) {
limit = (uintmax_t)((nfds_t)-1);
- if (limit > (uintmax_t)LONG_MAX) limit = (uintmax_t)LONG_MAX;
+ if (limit > (uintmax_t)LONG_MAX) {
+ limit = (uintmax_t)LONG_MAX;
+ }
}
+ check_value(options[i], "0", 1, 0);
+ check_value(options[i], "1", 1, 1);
+ check_value(options[i], "2", 1, 2);
+ check_value(options[i], "00015", limit >= 15, limit >= 15 ? 15 : previous);
+ check_value(options[i], "32 \t", limit >= 32, limit >= 32 ? 32 : previous);
+ check_value(options[i], "3600", limit >= 3600, limit >= 3600 ? 3600 : previous);
+ for (j = 0; j < sizeof(invalid) / sizeof(invalid[0]); j++)
+ check_value(options[i], invalid[j], 0, previous);
+
snprintf(number, sizeof(number), "%" PRIuMAX, limit - 1);
check_value(options[i], number, 1, limit - 1);
snprintf(number, sizeof(number), "%" PRIuMAX, limit);
@@ -209,15 +211,19 @@
snprintf(number, sizeof(number), "%" PRIuMAX, limit + 1);
check_value(options[i], number, 0, previous);
snprintf(number, sizeof(number), "%" PRIuMAX, (uintmax_t)LONG_MAX + 1);
- check_value(options[i], number, 0, previous);
+ if ((uintmax_t)LONG_MAX < limit) {
+ check_value(options[i], number, 1, (uintmax_t)LONG_MAX + 1);
+ } else {
+ check_value(options[i], number, 0, previous);
+ }
}
#if defined(WITH_SSL) && defined(WITH_CLIENT_CERTIFICATE_VALIDATION)
check_value("CERTREQUEST", "NO", 1, 0);
check_value("CERTREQUEST", "REQUEST", 1, 1);
check_value("CERTREQUEST", "REQUIRE", 1, 2);
check_value("CERTREQUEST", "require", 0, 2);
- /* ssl_init still owns the 0..2 domain check and its fatal error policy. */
- check_value("CERTREQUEST", "3", 1, 3);
+ /* Configuration parsing owns the 0..2 domain check. */
+ check_value("CERTREQUEST", "3", 0, 2);
#endif
f = fopen(config_file, "w");Signed-off-by: user01010111 lapses.50.booster@icloud.com |
|
@user01010111 : thanks for the research and confirmation! So after all it seems quite similar to what I did to this test program for #3640. I'll model the fix here on that code, after merging that PR then. |
|
No worries, @jimklimov .. Nice work as usual! 🫡 |
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ut_of_range and invalid_notnumber_notboolean standardized reports [networkupstools#677] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…rs are valid [networkupstools#677] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ations [networkupstools#677, #3840] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
❌ Build nut 2.8.5.5913-master failed (commit cca94791b0 by @jimklimov) |
|
✅ Build nut 2.8.5.5919-master completed (commit cca94791b0 by @jimklimov)
|
Closes #676
Signed-off-by: Arnaud Quette ArnaudQuette@eaton.com