diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2014-05-04 13:01:09 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2014-05-04 13:28:00 +0200 |
commit | 15fc13ce31cd6455d7c64089425da795da5d51d2 (patch) | |
tree | 1fbb0f99f89a9b05e012c66527e9892b47fbf93f /nslcd/myldap.c | |
parent | f9878913604c197a214b78f26782efd245237dda (diff) |
Warn when binddn buffer is too small
Diffstat (limited to 'nslcd/myldap.c')
-rw-r--r-- | nslcd/myldap.c | 18 |
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 |