components/openssh/patches/006-umac_align_fix.patch
changeset 1612 3f2ec017627f
equal deleted inserted replaced
1611:6b7edd68c53f 1612:3f2ec017627f
       
     1 #
       
     2 # This is to fix an alignment problem on Sparc.  We reported the problem to the
       
     3 # OpenSSH upstream community with suggested fixes in May 2013. The upstream 
       
     4 # accepted the union fix and has integrated the fix in the 6.3 release. In the 
       
     5 # future, when we upgrade OpenSSH to 6.3 or later, we should remove this patch.
       
     6 # For more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2101
       
     7 #
       
     8 --- orig/mac.c	Fri Sep 20 14:53:41 2013
       
     9 +++ new/mac.c	Fri Sep 20 15:04:13 2013
       
    10 @@ -132,12 +132,15 @@
       
    11  u_char *
       
    12  mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
       
    13  {
       
    14 -	static u_char m[EVP_MAX_MD_SIZE];
       
    15 +	static union {
       
    16 +		u_char m[EVP_MAX_MD_SIZE];
       
    17 +		u_int64_t for_align;
       
    18 +	} u;
       
    19  	u_char b[4], nonce[8];
       
    20  
       
    21 -	if (mac->mac_len > sizeof(m))
       
    22 +	if (mac->mac_len > sizeof(u))
       
    23  		fatal("mac_compute: mac too long %u %lu",
       
    24 -		    mac->mac_len, (u_long)sizeof(m));
       
    25 +		    mac->mac_len, (u_long)sizeof(u));
       
    26  
       
    27  	switch (mac->type) {
       
    28  	case SSH_EVP:
       
    29 @@ -146,17 +149,17 @@
       
    30  		HMAC_Init(&mac->evp_ctx, NULL, 0, NULL);
       
    31  		HMAC_Update(&mac->evp_ctx, b, sizeof(b));
       
    32  		HMAC_Update(&mac->evp_ctx, data, datalen);
       
    33 -		HMAC_Final(&mac->evp_ctx, m, NULL);
       
    34 +		HMAC_Final(&mac->evp_ctx, u.m, NULL);
       
    35  		break;
       
    36  	case SSH_UMAC:
       
    37  		put_u64(nonce, seqno);
       
    38  		umac_update(mac->umac_ctx, data, datalen);
       
    39 -		umac_final(mac->umac_ctx, m, nonce);
       
    40 +		umac_final(mac->umac_ctx, u.m, nonce);
       
    41  		break;
       
    42  	default:
       
    43  		fatal("mac_compute: unknown MAC type");
       
    44  	}
       
    45 -	return (m);
       
    46 +	return (u.m);
       
    47  }
       
    48  
       
    49  void