Set limit only when >2GB (not when equal), and set it to 2GB, not 2MB.
Based on patch from Andreas Longwitz.
... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Nov 23 13:13:40 EET 2010 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * clamd/clamd.c: fix RLIMIT_DATA setting on BSD (bb #1941), thanks to |
|
4 |
+ Andreas Longwitz <longwitz* incore.de>. |
|
5 |
+ |
|
1 | 6 |
Mon Nov 15 16:04:31 CET 2010 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* freshclam: improve mirror management |
... | ... |
@@ -307,14 +307,13 @@ int main(int argc, char **argv) |
307 | 307 |
* too soon (after ~120 MB). |
308 | 308 |
* Set limit lower than 2G if on 32-bit */ |
309 | 309 |
uint64_t lim = rlim.rlim_cur; |
310 |
- lim = (int32_t) lim; |
|
311 | 310 |
if (sizeof(void*) == 4 && |
312 |
- lim != rlim.rlim_cur) { |
|
313 |
- rlim.rlim_cur = 2048*1024-1; |
|
311 |
+ lim > (1ULL << 31)) { |
|
312 |
+ rlim.rlim_cur = 1ULL << 31; |
|
314 | 313 |
if (setrlimit(RLIMIT_DATA, &rlim) < 0) |
315 | 314 |
logg("!setrlimit(RLIMIT_DATA) failed: %s\n", strerror(errno)); |
316 | 315 |
else |
317 |
- logg("^Running on 32-bit system, and RLIMIT_DATA > 2GB, lowering to 2GB!\n"); |
|
316 |
+ logg("Running on 32-bit system, and RLIMIT_DATA > 2GB, lowering to 2GB!\n"); |
|
318 | 317 |
} |
319 | 318 |
} |
320 | 319 |
#endif |