5878ebb
diff -up openssh/sshd.c.ip-opts openssh/sshd.c
5878ebb
--- openssh/sshd.c.ip-opts	2016-07-25 13:58:48.998507834 +0200
5878ebb
+++ openssh/sshd.c	2016-07-25 14:01:28.346469878 +0200
f79c122
@@ -1507,12 +1507,32 @@ check_ip_options(struct ssh *ssh)
5878ebb
 
5878ebb
 	if (getsockopt(sock_in, IPPROTO_IP, IP_OPTIONS, opts,
49d0cf7
 	    &option_size) >= 0 && option_size != 0) {
49d0cf7
-		text[0] = '\0';
49d0cf7
-		for (i = 0; i < option_size; i++)
49d0cf7
-			snprintf(text + i*3, sizeof(text) - i*3,
5878ebb
-			    " %2.2x", opts[i]);
5878ebb
-		fatal("Connection from %.100s port %d with IP opts: %.800s",
5878ebb
-		    ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), text);
49d0cf7
+		i = 0;
49d0cf7
+		do {
5878ebb
+			switch (opts[i]) {
49d0cf7
+				case 0:
49d0cf7
+				case 1:
49d0cf7
+					++i;
49d0cf7
+					break;
94c6f8d
+				case 130:
94c6f8d
+				case 133:
94c6f8d
+				case 134:
f79c122
+					if (i + 1 < option_size && opts[i + 1] >= 2) {
f79c122
+						i += opts[i + 1];
f79c122
+						break;
f79c122
+					}
f79c122
+					/* FALLTHROUGH */
94c6f8d
+				default:
49d0cf7
+				/* Fail, fatally, if we detect either loose or strict
f79c122
+			 	 * or incorrect source routing options. */
49d0cf7
+					text[0] = '\0';
49d0cf7
+					for (i = 0; i < option_size; i++)
49d0cf7
+						snprintf(text + i*3, sizeof(text) - i*3,
5878ebb
+							" %2.2x", opts[i]);
5878ebb
+					fatal("Connection from %.100s port %d with IP options:%.800s",
5878ebb
+						ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), text);
49d0cf7
+			}
49d0cf7
+		} while (i < option_size);
49d0cf7
 	}
5878ebb
 	return;
49d0cf7
 #endif /* IP_OPTIONS */