Browse files

bugfix on ldap search. Crashing when entry name does not exists

  • Loading branch information...
1 parent 7a55b79 commit 805ea201c734a34a9cad8afada0ba9c76bf8ef14 root committed Jan 29, 2011
Showing with 17 additions and 10 deletions.
  1. +2 −2 client.c
  2. +1 −1 hiredis
  3. +6 −3 ldap.c
  4. +1 −1 main.c
  5. +7 −3 test_postfix_redis.py
View
4 client.c
@@ -219,7 +219,7 @@ void on_read(int fd, short ev, void *arg) {
sprintf(ldapSearchString, "%s", replace_email_parts(cfg.ldap_search_filter));
if(redis_lookup((char *) &response, &redis_pool, key) != 0) {
- syslog(LOG_INFO, "Missing key (%s) checking SQL", key);
+ syslog(LOG_INFO, "Missing key (%s) checking datasource", key);
/* lookup MySQL, if enabled */
if(!cfg.mysql_enabled == 0) {
@@ -249,7 +249,7 @@ void on_read(int fd, short ev, void *arg) {
strlen((char *) &result) ) +3,
"%s %s\n", POSTFIX_RESPONSE_OK, (char *) &result);
- syslog(LOG_INFO, "Key (%s) found on PostgreSQL", key);
+ syslog(LOG_INFO, "Key (%s) found on Directory", key);
}
else {
snprintf((char *)&response, strlen(POSTFIX_RESPONSE_ERROR) + 16,
2 hiredis
@@ -1 +1 @@
-Subproject commit c6b8bd77c0fe00dbc455b39208f15761178160a3
+Subproject commit e7aa0b4b5244b7c8a508067b2836b3f7e7137552
View
9 ldap.c
@@ -71,9 +71,12 @@ int tcp_mapper_ldap_search(LDAP *ldap, char *search, char *result){
/* just firts entry. We don't need any other */
entry = ldap_first_entry(ldap, ldap_result);
val = ldap_get_values(ldap, entry, cfg.ldap_result_attr);
-
- snprintf(result, strlen(val[0])+1, "%s", (char *) val[0]);
- ldap_value_free(val);
+
+ if(val == NULL) {
+ return 0;
+ }
+ snprintf(result, strlen(val[0])+1, "%s", (char *) val[0]);
+ ldap_value_free(val);
}
return numentries;
View
2 main.c
@@ -30,7 +30,7 @@
#include "tcp_mapper.h"
#define BACKLOG 1024
-#define MAX_EVENTS 2048
+#define MAX_EVENTS 65550
/* configuration file */
#include "config.h"
View
10 test_postfix_redis.py
@@ -9,7 +9,7 @@
def send(nada, dom_list):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect( ('127.0.0.1', 25000) )
+ s.connect( ('127.0.0.1', 25001) )
for i in range(0, times):
for d in dom_list:
s.send("get %s\r\n" % d)
@@ -22,7 +22,11 @@ def send(nada, dom_list):
for a in ascii_lowercase:
for b in ascii_lowercase:
for c in ascii_lowercase:
- domain.append("%s%s%s.com.br" % (a,b,c))
+ #domain.append("%s%s%s.com.br" % (a,b,c))
+ domain.append("leandro@mp13.com.br")
+ domain.append("leandro@namoskaonline.com.br")
+ domain.append("leandro@wishweb.com.br")
+ domain.append("leandro@expressonoturno.com.br")
size = len(domain) / num_threads
@@ -44,7 +48,7 @@ def send(nada, dom_list):
init_time = time.time()
i = 0
t = {}
-for i in len(div):
+for i in div:
t[i] = threading.Thread(target=send, args=(None, div[i]))
t[i].start()
i = i +1

0 comments on commit 805ea20

Please sign in to comment.