summaryrefslogtreecommitdiff
path: root/nslcd/myldap.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2014-05-04 13:01:09 +0200
committerArthur de Jong <arthur@arthurdejong.org>2014-05-04 13:28:00 +0200
commit15fc13ce31cd6455d7c64089425da795da5d51d2 (patch)
tree1fbb0f99f89a9b05e012c66527e9892b47fbf93f /nslcd/myldap.c
parentf9878913604c197a214b78f26782efd245237dda (diff)
Warn when binddn buffer is too small
Diffstat (limited to 'nslcd/myldap.c')
-rw-r--r--nslcd/myldap.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
index 9e0bc6e..8b97447 100644
--- a/nslcd/myldap.c
+++ b/nslcd/myldap.c
@@ -1031,14 +1031,30 @@ static int do_open(MYLDAP_SESSION *session)
}
/* Set alternative credentials for the session. */
-void myldap_set_credentials(MYLDAP_SESSION *session, const char *dn,
+int myldap_set_credentials(MYLDAP_SESSION *session, const char *dn,
const char *password)
{
+ /* error out when buffers are too small */
+ if (strlen(dn) >= sizeof(session->binddn))
+ {
+ log_log(LOG_ERR,
+ "myldap_set_credentials(): binddn buffer too small (%d required)",
+ strlen(dn));
+ return -1;
+ }
+ if (strlen(password) >= sizeof(session->bindpw))
+ {
+ log_log(LOG_ERR,
+ "myldap_set_credentials(): bindpw buffer too small (%d required)",
+ strlen(password));
+ return -1;
+ }
/* copy dn and password into session */
strncpy(session->binddn, dn, sizeof(session->binddn));
session->binddn[sizeof(session->binddn) - 1] = '\0';
strncpy(session->bindpw, password, sizeof(session->bindpw));
session->bindpw[sizeof(session->bindpw) - 1] = '\0';
+ return 0;
}
/* Get bind ppolicy results from the last bind operation. This function