bmh10 / rpms / openssh

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