2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

fix: usr: Properly calculate the amount of system memory

On 32 bit machines isc_meminfo_totalphys could return an incorrect value.

Closes #4799

Merge branch '4799-cid-498034-overflowed-return-value-integer_overflow' into 'main'

Closes #4799

See merge request isc-projects/bind9!9132
This commit is contained in:
Mark Andrews
2024-07-31 07:28:39 +00:00

View File

@@ -40,11 +40,11 @@ isc_meminfo_totalphys(void) {
long pages = sysconf(_SC_PHYS_PAGES);
long pagesize = sysconf(_SC_PAGESIZE);
if (pages == -1 || pagesize == -1) {
if (pages < 0 || pagesize < 0) {
return (0);
}
return ((size_t)pages * pagesize);
return ((uint64_t)pages * pagesize);
#endif /* if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) */
return (0);
}