components/w3m/patches/03-istream.patch
author Danek Duvall <danek.duvall@oracle.com>
Fri, 15 May 2015 11:21:43 -0700
branchs11-update
changeset 4318 7f2f7aebce6e
parent 3830 d9fd82448491
permissions -rw-r--r--
21063316 pkg update fails from s11.2.10.0.5 to s11.3_21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3830
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
# Copied over from the desktop consolidation, which has the comment:
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
# date:2011-02-16 owner:liyuan type bug bugster:7008664
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
# Bugster CR #7008664 is now BugDB CR #15688660
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
# 15688660 SUNBT7008664-SOLARIS_11 CVE-2010-2074 w3m problems handling x.509 data
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
#
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
# This patch needs to be evaluated to see if it needs to be passed upstream.
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
--- w3m-0.5.2/istream.c	2007-05-23 23:06:05.000000000 +0800
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
+++ w3m-0.5.3/istream.c	2011-01-04 17:22:22.000000000 +0800
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
@@ -1,4 +1,4 @@
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
-/* $Id: istream.c,v 1.26 2007/05/23 15:06:05 inu Exp $ */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
+/* $Id: istream.c,v 1.27 2010/07/18 13:43:23 htrb Exp $ */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
 #include "fm.h"
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
 #include "myctype.h"
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
 #include "istream.h"
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
@@ -447,8 +447,17 @@
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
 
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
 		    if (!seen_dnsname)
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
 			seen_dnsname = Strnew();
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+		    /* replace \0 to make full string visible to user */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
+		    if (sl != strlen(sn)) {
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
+			int i;
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
+			for (i = 0; i < sl; ++i) {
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
+			    if (!sn[i])
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
+				sn[i] = '!';
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
+			}
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
+		    }
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
 		    Strcat_m_charp(seen_dnsname, sn, " ", NULL);
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
-		    if (ssl_match_cert_ident(sn, sl, hostname))
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
+		    if (sl == strlen(sn) /* catch \0 in SAN */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
+			&& ssl_match_cert_ident(sn, sl, hostname))
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
 			break;
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
 		}
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
 	    }
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
@@ -466,16 +475,27 @@
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
     if (match_ident == FALSE && ret == NULL) {
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
 	X509_NAME *xn;
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
 	char buf[2048];
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
+	int slen;
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
 
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
 	xn = X509_get_subject_name(x);
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
 
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
-	if (X509_NAME_get_text_by_NID(xn, NID_commonName,
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
-				      buf, sizeof(buf)) == -1)
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
+	slen = X509_NAME_get_text_by_NID(xn, NID_commonName, buf, sizeof(buf));
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
+	if ( slen == -1)
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
 	    /* FIXME: gettextize? */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
 	    ret = Strnew_charp("Unable to get common name from peer cert");
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
-	else if (!ssl_match_cert_ident(buf, strlen(buf), hostname))
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
+	else if (slen != strlen(buf)
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    51
+		|| !ssl_match_cert_ident(buf, strlen(buf), hostname)) {
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    52
+	    /* replace \0 to make full string visible to user */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    53
+	    if (slen != strlen(buf)) {
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    54
+		int i;
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    55
+		for (i = 0; i < slen; ++i) {
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    56
+		    if (!buf[i])
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    57
+			buf[i] = '!';
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    58
+		}
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    59
+	    }
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    60
 	    /* FIXME: gettextize? */
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    61
 	    ret = Sprintf("Bad cert ident %s from %s", buf, hostname);
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    62
+	}
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    63
 	else
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    64
 	    match_ident = TRUE;
d9fd82448491 20146056 Move w3m from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    65
     }