kentpeacock / rpms / openssh

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