Browse Source

Resolves: 328741
Summary: Ensure that we NULL terminate strings properly when processing config file settings.

Nathan Kinder 18 years ago
parent
commit
6e0b12928e
1 changed files with 4 additions and 0 deletions
  1. 4 0
      ldap/servers/snmp/main.c

+ 4 - 0
ldap/servers/snmp/main.c

@@ -264,6 +264,10 @@ load_config(char *conf_path)
             if ((pidfile = malloc((p - conf_path) +
                                    strlen(LDAP_AGENT_PIDFILE) + 2)) != NULL) {
                 strncpy(pidfile, conf_path, (p - conf_path + 1));
+                /* The above will likely not be NULL terminated, but we need to
+                 * be sure that we're properly NULL terminated for the below
+                 * strcat() to work properly. */
+                pidfile[(p - conf_path + 2)] = (char)0;
                 strcat(pidfile, LDAP_AGENT_PIDFILE);
                 pidfile[((p - conf_path) + strlen(LDAP_AGENT_PIDFILE) + 1)] = (char)0;
             } else {