Browse Source

Don't strlen() on possibly null pointer

Conflicts:
	bin/konfd.c
Serj Kalichev 10 years ago
parent
commit
03c8558b2a
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(konf_buf_t *tbuf, 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);
@@ -522,8 +522,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);
 }