jonathancammack / rpms / openssh

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