Переглянути джерело

Resolves: #178248
Summary: db backend entry cache settings field "Memory available for cache" boundaries
Fix Description:
db_strtoul: check the input string. If the string starts with '-', returning
the error ERANGE -- the same error as the larger the upper limit is passed.
cache.c: the minimum entry cache size defined in cache.c was 200000, which is
different from the info on the Configuration Command File Reference Guide:
Valid Range: 500 kilobytes to 4 gigabytes for 32-bit platforms and 500
kilobytes to 2^64-1 for 64-bit platforms
Adjusting the define to the doc.

Noriko Hosoi 17 роки тому
батько
коміт
5a6572622c

+ 1 - 1
ldap/servers/slapd/back-ldbm/cache.c

@@ -50,7 +50,7 @@
 #endif
 
 /* cache can't get any smaller than this (in bytes) */
-#define MINCACHESIZE       (size_t)200000
+#define MINCACHESIZE       (size_t)512000
 
 /* don't let hash be smaller than this # of slots */
 #define MINHASHSIZE       1024

+ 11 - 1
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -3875,10 +3875,20 @@ PRInt64 db_atoi(char *str, int *err)
 
 unsigned long db_strtoul(const char *str, int *err)
 {
-    unsigned long val, result, multiplier = 1;
+    unsigned long val = 0, result, multiplier = 1;
     char *p;
     errno = 0;
 
+    /*
+     * manpage of strtoul: Negative  values  are considered valid input and
+     * are silently converted to the equivalent unsigned long int value.
+     */
+    /* We don't want to make it happen. */
+    for (p = str; p && *p && (*p == ' ' || *p == '\t'); p++) ;
+    if ('-' == *p) {
+        if (err) *err = ERANGE;
+        return val;
+    }
     val = strtoul(str, &p, 10);
     if (errno != 0) {
         if (err) *err = errno;