Browse Source

Don't strlen() on possible yull l pointer

Serj Kalichev 10 years ago
parent
commit
979c7f16de
1 changed files with 6 additions and 2 deletions
  1. 6 2
      bin/konfd.c

+ 6 - 2
bin/konfd.c

@@ -71,7 +71,7 @@ static void sighandler(int signo);
 
 static void help(int status, const char *argv0);
 static char * process_query(int sock, konf_tree_t * conf, char *str);
-int answer_send(int sock, char *command);
+int answer_send(int sock, const char *command);
 static int dump_running_config(int sock, konf_tree_t *conf, konf_query_t *query);
 int daemonize(int nochdir, int noclose);
 struct options *opts_init(void);
@@ -458,8 +458,12 @@ static void sighandler(int signo)
 }
 
 /*--------------------------------------------------------- */
-int answer_send(int sock, char *command)
+int answer_send(int sock, const char *command)
 {
+	if (!command) {
+		errno = EINVAL;
+		return -1;
+	}
 	return send(sock, command, strlen(command) + 1, MSG_NOSIGNAL);
 }