Browse Source

The konf can escape encode arguments before passing them to the konfd daemon.

git-svn-id: https://klish.googlecode.com/svn/trunk@214 0eaa4687-2ee9-07dd-09d9-bcdd2d2dd5fb
Serj Kalichev 13 years ago
parent
commit
e7e65d4623
1 changed files with 5 additions and 1 deletions
  1. 5 1
      bin/konf.c

+ 5 - 1
bin/konf.c

@@ -25,6 +25,8 @@ static int receive_answer(konf_client_t * client, konf_buf_t **data);
 static int receive_data(konf_client_t * client, konf_buf_t *buf, konf_buf_t **data);
 static int process_answer(konf_client_t * client, char *str, konf_buf_t *buf, konf_buf_t **data);
 
+static const char *escape_chars = "\"\\'";
+
 /*--------------------------------------------------------- */
 int main(int argc, char **argv)
 {
@@ -44,7 +46,9 @@ int main(int argc, char **argv)
 		space = strchr(argv[i], ' ');
 		if (space)
 			lub_string_cat(&line, "\"");
-		lub_string_cat(&line, argv[i]);
+		str = lub_string_encode(argv[i], escape_chars);
+		lub_string_cat(&line, str);
+		lub_string_free(str);
 		if (space)
 			lub_string_cat(&line, "\"");
 	}