summaryrefslogtreecommitdiffstats
path: root/web/attachments/310361-nagios-1.4.13-no_pass.diff
blob: b621967ef3ddc9ab6393f1151e9b837d6d49dc2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--- nagios-plugins-1.4.13/plugins/check_mysql.c	2008-08-16 00:47:32.000000000 -0400
+++ nagios-plugins-1.4.13-no_pass/plugins/check_mysql.c	2009-01-23 18:10:48.000000000 -0500
@@ -265,7 +265,7 @@
 		return ERROR;
 
 	while (1) {
-		c = getopt_long (argc, argv, "hvVSP:p:u:d:H:s:c:w:", longopts, &option);
+		c = getopt_long (argc, argv, "hvVSP:p::u:d:H:s:c:w:", longopts, &option);
 
 		if (c == -1 || c == EOF)
 			break;
@@ -289,12 +289,16 @@
 			db_user = optarg;
 			break;
 		case 'p':									/* authentication information: password */
-			db_pass = strdup(optarg);
-
-			/* Delete the password from process list */
-			while (*optarg != '\0') {
-				*optarg = 'X';
-				optarg++;
+			if (optarg == NULL)
+				db_pass = strdup("");
+			else
+			{
+				db_pass = strdup(optarg);
+				/* Delete the password from process list */
+				while (*optarg != '\0') {
+					*optarg = 'X';
+					optarg++;
+				}
 			}
 			break;
 		case 'P':									/* critical time threshold */
@@ -361,9 +365,6 @@
 	if (db_host == NULL)
 		db_host = strdup("");
 
-	if (db_pass == NULL)
-		db_pass = strdup("");
-
 	if (db == NULL)
 		db = strdup("");