rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone

Blame SOURCES/openssh-6.6p1-allow-ip-opts.patch

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