summaryrefslogtreecommitdiffstats
path: root/ldap/servers/snmp
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2005-03-31 19:16:16 +0000
committerNathan Kinder <nkinder@redhat.com>2005-03-31 19:16:16 +0000
commitc62623c876b99d582c238b857d12b26ed92e477b (patch)
treeb5af5dfe43e1d5ffe51d5fda492841e4cb43fb9b /ldap/servers/snmp
parent6af610276381854408dfa3249f7afb3a38a8ad19 (diff)
downloadds-c62623c876b99d582c238b857d12b26ed92e477b.tar.gz
ds-c62623c876b99d582c238b857d12b26ed92e477b.tar.xz
ds-c62623c876b99d582c238b857d12b26ed92e477b.zip
Ensure null termination of strings in SNMP code
Diffstat (limited to 'ldap/servers/snmp')
-rw-r--r--ldap/servers/snmp/main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 9836b066..e8bcd9e8 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -39,7 +39,7 @@ main (int argc, char *argv[]) {
/* Load options */
while ((--argc > 0) && ((*++argv)[0] == '-')) {
- while (c = *++argv[0]) {
+ while ((c = *++argv[0])) {
switch (c) {
case 'D':
log_level = LOG_DEBUG;
@@ -109,6 +109,7 @@ main (int argc, char *argv[]) {
if (*(agent_logdir + strlen(agent_logdir)) != '/')
strcat((char *) log_hdl->token, "/");
strcat((char *) log_hdl->token, LDAP_AGENT_LOGFILE);
+ ((char*)log_hdl->token)[(strlen(agent_logdir) + strlen(LDAP_AGENT_LOGFILE) + 1)] = (char)0;
}
} else {
/* agent-logdir not set */
@@ -134,7 +135,7 @@ main (int argc, char *argv[]) {
/* run as a daemon */
if (netsnmp_daemonize(0, 0)) {
/* sleep to allow pidfile to be created by child */
- sleep(3);
+ sleep(5);
if((pid_fp = fopen(pidfile,"r")) == NULL) {
printf("ldap-agent: Not started! Check log file for details.\n");
exit(1);
@@ -224,6 +225,7 @@ load_config(char *conf_path)
strlen(LDAP_AGENT_PIDFILE) + 2)) != NULL) {
strncpy(pidfile, conf_path, (p - conf_path + 1));
strcat(pidfile, LDAP_AGENT_PIDFILE);
+ pidfile[((p - conf_path) + strlen(LDAP_AGENT_PIDFILE) + 1)] = (char)0;
} else {
printf("ldap-agent: malloc error processing config file\n");
exit(1);
@@ -232,6 +234,7 @@ load_config(char *conf_path)
/* set default logdir to location of config file */
if ((agent_logdir = malloc((p - conf_path) + 1)) != NULL) {
strncpy(agent_logdir, conf_path, (p - conf_path));
+ agent_logdir[(p - conf_path)] = (char)0;
break;
} else {
printf("ldap-agent: malloc error processing config file\n");
@@ -278,8 +281,10 @@ load_config(char *conf_path)
if ((serv_p->stats_file = malloc(strlen(p) + 18)) != NULL)
snprintf(serv_p->stats_file, strlen(p) + 18,
"%s/logs/slapd.stats", p);
+ serv_p->stats_file[(strlen(p) + 17)] = (char)0;
if ((serv_p->dse_ldif = malloc(strlen(p) + 17)) != NULL) {
snprintf(serv_p->dse_ldif, strlen(p) + 17, "%s/config/dse.ldif", p);
+ serv_p->dse_ldif[(strlen(p) + 16)] = (char)0;
}
}