File: 1053_dont-count-ldap-result-object-if-false.patch

package info (click to toggle)
gosa 2.8~git20230203.10abe45%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 33,108 kB
  • sloc: php: 32,102; javascript: 10,836; pascal: 3,776; xml: 3,135; sh: 852; python: 162; makefile: 45; perl: 2
file content (33 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Description: Don't count LDAP objects if search/list result is false (bool).
Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>

--- a/include/functions.inc
+++ b/include/functions.inc
@@ -3803,7 +3803,12 @@
             array('dn'));
 
     // If we haven't created the character-detection object, then create it now.
-    $cnt = ldap_count_entries($ldapCID, $res);
+    if ($res) {
+        $cnt = ldap_count_entries($ldapCID, $res);
+    }
+    else {
+        $cnt = 0;
+    }
     if(!$cnt){
         $obj = array();
         $obj['objectClass'] = array('top','organization');
@@ -3819,7 +3824,12 @@
     $res = ldap_list($ldapCID, $config->current['BASE'],
             "(&(o=".$filterName.")(objectClass=organization))",
             array('dn','o'));
-    $cnt = ldap_count_entries($ldapCID, $res);
+    if ($res) {
+        $cnt = ldap_count_entries($ldapCID, $res);
+    }
+    else {
+        $cnt = 0;
+    }
     if($cnt != 1 || !$res){
         trigger_error("GOsa couldn't detect the special character handling used by your ldap!");
         return(NULL);