vishalmishra434 / rpms / openssh

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