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
|
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Fri, 10 Mar 2017 00:28:52 +0100
Subject: [PATCH] Fix segfault in lualdap_open_simple()
--- a/src/lualdap.c
+++ b/src/lualdap.c
@@ -1011,7 +1011,7 @@
int use_tls = lua_toboolean (L, 4);
conn_data *conn = (conn_data *)lua_newuserdata (L, sizeof(conn_data));
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300
- struct berval cred = { 0, NULL };
+ struct berval *cred = NULL;
char *host_with_schema = NULL;
#endif
int err;
@@ -1045,12 +1045,9 @@
}
/* Bind to a server */
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300
- cred.bv_len = strlen(password);
- cred.bv_val = malloc(cred.bv_len+1);
- strcpy(cred.bv_val, password);
- err = ldap_sasl_bind_s (conn->ld, who, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
- free(cred.bv_val);
- memset(&cred, 0, sizeof(cred));
+ cred = ber_bvstrdup(password);
+ err = ldap_sasl_bind_s (conn->ld, who, LDAP_SASL_SIMPLE, cred, NULL, NULL, NULL);
+ ber_bvfree(cred);
#else
err = ldap_bind_s (conn->ld, who, password, LDAP_AUTH_SIMPLE);
#endif
|