aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@novell.com>2004-08-03 01:46:03 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-08-03 01:46:03 +0800
commit1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2 (patch)
treedb12a220a152343c378950c55b3399fa10bdeb74
parent86de6327c60a1e772ddeeb16dbb1b8081e526f92 (diff)
downloadgsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.tar
gsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.tar.gz
gsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.tar.bz2
gsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.tar.lz
gsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.tar.xz
gsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.tar.zst
gsoc2013-evolution-1b83ca38ebf6c8f45bd4d2fc32bdf2055824c4b2.zip
Fixed to work for both LE and BE architectures.
2004-08-02 Jeffrey Stedfast <fejj@novell.com> * lib/e-pkcs12.c (prompt_for_password): Fixed to work for both LE and BE architectures. svn path=/trunk/; revision=26794
-rw-r--r--smime/ChangeLog5
-rw-r--r--smime/lib/e-pkcs12.c33
2 files changed, 20 insertions, 18 deletions
diff --git a/smime/ChangeLog b/smime/ChangeLog
index 0c5db3c700..26e5a32bb2 100644
--- a/smime/ChangeLog
+++ b/smime/ChangeLog
@@ -1,3 +1,8 @@
+2004-08-02 Jeffrey Stedfast <fejj@novell.com>
+
+ * lib/e-pkcs12.c (prompt_for_password): Fixed to work for both LE
+ and BE architectures.
+
2004-07-16 Chris Toshok <toshok@ximian.com>
[ fixes #61490 ]
diff --git a/smime/lib/e-pkcs12.c b/smime/lib/e-pkcs12.c
index 14eea35fe6..faf73c93bd 100644
--- a/smime/lib/e-pkcs12.c
+++ b/smime/lib/e-pkcs12.c
@@ -222,26 +222,23 @@ prompt_for_password (char *title, char *prompt, SECItem *pwd)
NULL);
if (passwd) {
- int len = g_utf8_strlen (passwd, -1);
- gunichar2 uni;
- int i;
- char *p;
-
+ size_t len = strlen (passwd);
+ const char *inptr = passwd;
+ char *outptr = pwd->data;
+ gunichar2 c;
+
SECITEM_AllocItem(NULL, pwd, sizeof (gunichar2) * (len + 1));
- memset (pwd->data, 0, sizeof (gunichar2) * (len + 1));
-
-#ifdef IS_LITTLE_ENDIAN
- p = passwd;
- for (i=0; i < len; i++) {
- uni = (gunichar2)(g_utf8_get_char (p) & 0xFFFF);
- p = g_utf8_next_char (p);
-
- pwd->data[2*i] = (unsigned char)(uni >> 8);
- pwd->data[2*i+1] = (unsigned char)(uni & 0xFF);
+
+ while (inptr && (c = (gunichar2) (g_utf8_get_char (inptr) & 0xffff))) {
+ inptr = g_utf8_next_char (inptr);
+ c = GUINT16_TO_BE (c);
+ *outptr++ = ((char *) &c)[0];
+ *outptr++ = ((char *) &c)[1];
}
-#else
- memcpy (pwd->data, uni, pwd->len-2);
-#endif
+
+ *outptr++ = 0;
+ *outptr++ = 0;
+
memset (passwd, 0, strlen (passwd));
g_free (passwd);
}