[gnutls-dev] Unaligned access on IA64
Ian Wienand
ianw at gelato.unsw.edu.au
Thu Sep 25 05:03:02 CEST 2003
Hi,
GNUTLS is causing some unaligned access warnings on IA64. See
http://www.gelato.unsw.edu.au/linux-ia64/0309/6847.html for a small
discussion about my findings.
Anyway, suggested patch attached.
2003-09-25 Ian Wienand <ianw at ieee.org>
* lib/gnutls_handshake.c : modifiy to use memcpy in
_gnutls_server_select_suite and
_gnutls_server_find_pk_algos_in_ciphersuites
to stop alignment problems on IA64.
-i
ianw at gelato.unsw.edu.au
http://www.gelato.unsw.edu.au
-------------- next part --------------
--- ./gnutls7-0.8.9/lib/gnutls_handshake.c 2003-02-04 23:52:24.000000000 +1100
+++ gnutls7-0.8.9-align/lib/gnutls_handshake.c 2003-09-25 13:03:22.000000000 +1000
@@ -509,9 +509,11 @@
int j;
gnutls_pk_algorithm algo=-1, prev_algo = 0;
gnutls_kx_algorithm kx;
+GNUTLS_CipherSuite cs;
for (j = 0; j < datalen; j += 2) {
- kx = _gnutls_cipher_suite_get_kx_algo(*((GNUTLS_CipherSuite *) & data[j]));
+ memcpy(&cs, &data[j], sizeof(GNUTLS_CipherSuite));
+ kx = _gnutls_cipher_suite_get_kx_algo(cs);
if ( _gnutls_map_kx_get_cred( kx, 1) == GNUTLS_CRD_CERTIFICATE) {
algo = _gnutls_map_pk_get_pk( kx);
@@ -531,7 +533,7 @@
int _gnutls_server_select_suite(gnutls_session session, opaque *data, int datalen)
{
int x, i, j;
- GNUTLS_CipherSuite *ciphers;
+ GNUTLS_CipherSuite *ciphers,cs;
int retval, err;
gnutls_pk_algorithm pk_algo; /* will hold the pk algorithms
* supported by the peer.
@@ -558,10 +560,10 @@
#ifdef HANDSHAKE_DEBUG
_gnutls_handshake_log("HSK: Requested cipher suites: \n");
- for (j = 0; j < datalen; j += 2)
- _gnutls_handshake_log("\t%s\n",
- _gnutls_cipher_suite_get_name(*
- ((GNUTLS_CipherSuite *) & data[j])));
+ for (j = 0; j < datalen; j += 2) {
+ memcpy(&cs, &data[j], sizeof(GNUTLS_CipherSuite));
+ _gnutls_handshake_log("\t%s\n", _gnutls_cipher_suite_get_name(cs));
+ }
_gnutls_handshake_log("HSK: Supported cipher suites: \n");
for (j = 0; j < x; j++)
_gnutls_handshake_log("\t%s\n",
@@ -575,11 +577,11 @@
for (i = 0; i < x; i++) {
if (memcmp(ciphers[i].CipherSuite, &data[j], 2) ==
0) {
+ memcpy(&cs, &data[j], sizeof(GNUTLS_CipherSuite));
_gnutls_handshake_log("HSK: Selected cipher suite: ");
- _gnutls_handshake_log("%s\n",
- _gnutls_cipher_suite_get_name(*
- ((GNUTLS_CipherSuite *) & data[j])));
- memcpy(session->security_parameters.current_cipher_suite.CipherSuite, ciphers[i].CipherSuite, 2);
+ _gnutls_handshake_log("%s\n", _gnutls_cipher_suite_get_name(cs));
+ memcpy(session->security_parameters.current_cipher_suite.CipherSuite,
+ ciphers[i].CipherSuite, 2);
retval = 0;
goto finish;
}
More information about the Gnutls-devel
mailing list