Просмотр исходного кода

check_mysql_query & mysql_query: extra-opts causes crash

Fix for issue #221
John C. Frickson 8 лет назад
Родитель
Сommit
2eeee518da
2 измененных файлов с 5 добавлено и 1 удалено
  1. 1 0
      NEWS
  2. 4 1
      lib/parse_ini.c

+ 1 - 0
NEWS

@@ -5,6 +5,7 @@ This file documents the major additions and syntax changes between releases.
 	check_disk: autofs being mounted despite '-l'. Fixed, and also excluded some system "fake" mountpoints
 	check_ntp_time: Periodically returns "Socket timeout" when one of several ntp server doesn't respond
 	check_ntp_time calls `write` on a UDP socket without a successful call to `connect`
+	check_mysql_query & mysql_query: extra-opts causes crash
 
 
 2.2.1 2017-04-19

+ 4 - 1
lib/parse_ini.c

@@ -83,6 +83,7 @@ static char* default_file_in_path(void);
  */
 static void parse_locator(const char *locator, const char *def_stanza, np_ini_info *i){
 	size_t locator_len=0, stanza_len=0;
+	char *dflt = NULL;
 
 	/* if locator is NULL we'll use default values */
 	if(locator){
@@ -102,7 +103,9 @@ static void parse_locator(const char *locator, const char *def_stanza, np_ini_in
 	}
 	/* if there is no @file part */
 	if(stanza_len==locator_len){
-		i->file=default_file();
+		dflt=default_file();
+		if (dflt)
+			i->file=strdup(dflt);
 	} else {
 		i->file=strdup(&(locator[stanza_len+1]));
 	}