summaryrefslogtreecommitdiff
path: root/nslcd/cfg.c
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2014-05-04 14:38:02 +0200
committerArthur de Jong <arthur@arthurdejong.org>2014-05-04 14:57:09 +0200
commit2274b41dcb6bbb2557ab0e4358a11f1d54da12d7 (patch)
tree553de2872797d8ccf0d1316889e8d7d344f64d34 /nslcd/cfg.c
parent15fc13ce31cd6455d7c64089425da795da5d51d2 (diff)
Make buffer size error logging consistent
This adds logging of most cases where a defined buffer is not large enough to hold provided data on error log level.
Diffstat (limited to 'nslcd/cfg.c')
-rw-r--r--nslcd/cfg.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/nslcd/cfg.c b/nslcd/cfg.c
index e1857d5..1d99962 100644
--- a/nslcd/cfg.c
+++ b/nslcd/cfg.c
@@ -5,7 +5,7 @@
Copyright (C) 1997-2005 Luke Howard
Copyright (C) 2007 West Consulting
- Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Arthur de Jong
+ Copyright (C) 2007-2014 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -455,14 +455,24 @@ static void add_uris_from_dns(const char *filename, int lnr,
if ((strlen(hostlist) > 4) && (strcmp(hostlist + strlen(hostlist) - 4, ":636") == 0))
{
hostlist[strlen(hostlist) - 4] = '\0';
- mysnprintf(buf, sizeof(buf), "ldaps://%s", hostlist);
+ if (mysnprintf(buf, sizeof(buf), "ldaps://%s", hostlist))
+ {
+ log_log(LOG_ERR, "add_uris_from_dns(): buf buffer too small (%d required)",
+ strlen(hostlist) + 8);
+ exit(EXIT_FAILURE);
+ }
}
else
{
/* strip default port number */
if ((strlen(hostlist) > 4) && (strcmp(hostlist + strlen(hostlist) - 4, ":389") == 0))
hostlist[strlen(hostlist) - 4] = '\0';
- mysnprintf(buf, sizeof(buf), "ldap://%s", hostlist);
+ if (mysnprintf(buf, sizeof(buf), "ldap://%s", hostlist))
+ {
+ log_log(LOG_ERR, "add_uris_from_dns(): buf buffer too small (%d required)",
+ strlen(hostlist) + 7);
+ exit(EXIT_FAILURE);
+ }
}
log_log(LOG_DEBUG, "add_uris_from_dns(): found uri: %s", buf);
add_uri(filename, lnr, cfg, buf);