Commit Diff


commit - 421c9a869ac123f10541b043bb90c9732c53a182
commit + a37af028384e1634eff1c86a2613aada7a4ba5ec
blob - 058ec505a4fc0414c12fdbc283f639e34db14327
blob + 0c1414fbb658de7a0d751983512466dc20244838
--- opensmtpd.c
+++ opensmtpd.c
@@ -901,7 +901,8 @@ osmtpd_run(void)
 	int registered = 0;
 	/* Doesn't leak, since it needs to exists until the application ends. */
 	struct io *io_stdin;
-	struct osmtpd_callback *hidenity, *eidentity, *ridentity;
+	struct osmtpd_callback *hidenity = NULL, *eidentity = NULL;
+	struct osmtpd_callback *ridentity = NULL;
 
 	event_init();
 
@@ -944,10 +945,10 @@ osmtpd_run(void)
 				ridentity = &(osmtpd_callbacks[i]);
 		}
 	}
-	if (ridentity->storereport) {
-		if (hidenity->doregister)
+	if (ridentity != NULL && ridentity->storereport) {
+		if (hidenity != NULL && hidenity->doregister)
 			hidenity->storereport = 1;
-		if (eidentity->doregister)
+		if (eidentity != NULL && eidentity->doregister)
 			eidentity->storereport = 1;
 	}
 	for (i = 0; i < NITEMS(osmtpd_callbacks); i++) {
@@ -1935,7 +1936,7 @@ static void
 osmtpd_addrtoss(char *addr, struct sockaddr_storage *ss, int hasport,
     char *linedup)
 {
-	char *port;
+	char *port = NULL;
 	const char *errstr = NULL;
 	struct sockaddr_in *sin;
 	struct sockaddr_in6 *sin6;
@@ -1962,11 +1963,13 @@ osmtpd_addrtoss(char *addr, struct sockaddr_storage *s
 		case 1:
 			break;
 		case 0:
-			port[-1] = ':';
+			if (hasport)
+				port[-1] = ':';
 			osmtpd_errx(1, "Invalid line received: invalid address "
 			    "(%s): %s", addr, linedup);
 		default:
-			port[-1] = ':';
+			if (hasport)
+				port[-1] = ':';
 			osmtpd_err(1, "Can't parse address (%s): %s", addr,
 			    linedup);
 		}
@@ -2000,11 +2003,13 @@ osmtpd_addrtoss(char *addr, struct sockaddr_storage *s
 		case 1:
 			break;
 		case 0:
-			port[-1] = ':';
+			if (hasport)
+				port[-1] = ':';
 			osmtpd_errx(1, "Invalid line received: invalid address "
 			    "(%s): %s", addr, linedup);
 		default:
-			port[-1] = ':';
+			if (hasport)
+				port[-1] = ':';
 			osmtpd_err(1, "Can't parse address (%s): %s", addr,
 			    linedup);
 		}