jonathancammack / rpms / openssh

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