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