[9.18] fix: usr: Properly calculate the amount of system memory
On 32 bit machines isc_meminfo_totalphys could return an incorrect value. Closes #4799 Backport of MR !9132 Merge branch 'backport-4799-cid-498034-overflowed-return-value-integer_overflow-9.18' into 'bind-9.18' See merge request isc-projects/bind9!9200
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user