kentpeacock / rpms / openssh

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