Commit Diff


commit - 2a3d7bdf6560616335e68a0fa1ea99133cd97a2b
commit + 183acf206b8693212cbce187915c05172ed56615
blob - 2b0379ceb3e52e0716acd17d37bdedaf1e1858f2
blob + fa7206abe42133da80b85f141b971786f4572e40
--- opensmtpd.c
+++ opensmtpd.c
@@ -1007,16 +1007,22 @@ osmtpd_newline(struct io *io, int ev, void *arg)
 			osmtpd_errx(1, "Invalid line received: unknown message "
 			    "type: %s", linedup);
 		line = end;
-		if ((end = strchr(line, '|')) == NULL)
+		version_major = strtoul(line, &end, 10);
+		if (line == end || end[0] != '.')
+			osmtpd_errx(1, "Invalid protocol received: %s",
+			    linedup);
+		line = end + 1;
+		version_minor = strtoul(line, &end, 10);
+		if (end[0] == '\0')
 			osmtpd_errx(1, "Invalid line received: missing time: "
 			    "%s", linedup);
-		end++[0] = '\0';
-		if (strcmp(line, "0.1") != 0)
+		if (line == end || end[0] != '|')
+			osmtpd_errx(1, "Invalid protocol received: %s",
+			    linedup);
+		if (version_major != 0)
 			osmtpd_errx(1, "Unsupported protocol received: %s",
 			    linedup);
-		version_major = 0;
-		version_minor = 1;
-		line = end;
+		line = end + 1;
 		if ((end = strchr(line, '.')) == NULL)
 			osmtpd_errx(1, "Invalid line received: invalid "
 			    "timestamp: %s", linedup);