Avoid false buffer overflow warning in GCC 11

GCC 11 can’t prove PRIu64 won’t expand beyond two digits, so we switch this formatter to bounded unsigned int fields (%02u) after clamping logic.
This commit is contained in:
Philippe Teuwen
2026-05-22 19:06:43 +02:00
parent 20aaf4c292
commit 65de25c67e
+5 -5
View File
@@ -5050,16 +5050,16 @@ static uint64_t mfulc_desbrute_tdea2_dec_ip(uint64_t ip_block, const uint64_t k1
}
static void mfulc_desbrute_format_duration(uint64_t seconds, char *buf, size_t buflen) {
uint64_t h = seconds / 3600;
uint64_t m = (seconds / 60) % 60;
uint64_t s = seconds % 60;
unsigned int h = (unsigned int)(seconds / 3600);
unsigned int m = (unsigned int)((seconds / 60) % 60);
unsigned int s = (unsigned int)(seconds % 60);
if (h > 99) {
snprintf(buf, buflen, ">99h");
} else if (h > 0) {
snprintf(buf, buflen, "%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64, h, m, s);
snprintf(buf, buflen, "%02u:%02u:%02u", h, m, s);
} else {
snprintf(buf, buflen, "%02" PRIu64 ":%02" PRIu64, m, s);
snprintf(buf, buflen, "%02u:%02u", m, s);
}
}