The branch, master has been updated via dd504b1 HEIMDAL:lib/krb5: add utf8 support to build_logon_name() for the PAC via d158a5c HEIMDAL:lib/wind: export wind_ucs2write() via a01de42 HEIMDAL:lib/winbd: fix wind_ucs2write with WIND_RW_LE via 1312e90 HEIMDAL:lib/wind: fix wind_ucs4utf8() and wind_ucs2utf8() from 3ede4ff Fix bug #8561 - Password change settings not fully observed.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit dd504b1899f437a4b877475bba3b5b2b04f400e1 Author: Stefan Metzmacher <me...@samba.org> Date: Tue Nov 15 14:32:35 2011 +0100 HEIMDAL:lib/krb5: add utf8 support to build_logon_name() for the PAC Pair-Programmed-With: Arvid Requate <requ...@univention.de> metze Autobuild-User: Stefan Metzmacher <me...@samba.org> Autobuild-Date: Wed Nov 16 02:00:12 CET 2011 on sn-devel-104 commit d158a5cb915f1d04952cf943d043f452d1f3184b Author: Stefan Metzmacher <me...@samba.org> Date: Tue Nov 15 14:38:38 2011 +0100 HEIMDAL:lib/wind: export wind_ucs2write() Pair-Programmed-With: Arvid Requate <requ...@univention.de> metze commit a01de42a3636c9bb98fd64de8b4035023223b58b Author: Stefan Metzmacher <me...@samba.org> Date: Tue Nov 15 15:57:40 2011 +0100 HEIMDAL:lib/winbd: fix wind_ucs2write with WIND_RW_LE Pair-Programmed-With: Arvid Requate <requ...@univention.de> metze commit 1312e9027945898a7352e22cfaf127e7ffc8327a Author: Stefan Metzmacher <me...@samba.org> Date: Tue Nov 15 15:57:10 2011 +0100 HEIMDAL:lib/wind: fix wind_ucs4utf8() and wind_ucs2utf8() Pair-Programmed-With: Arvid Requate <requ...@univention.de> metze ----------------------------------------------------------------------- Summary of changes: source4/heimdal/lib/krb5/pac.c | 67 +++++++++++++++++++------- source4/heimdal/lib/wind/utf8.c | 18 ++++---- source4/heimdal/lib/wind/version-script.map | 1 + 3 files changed, 59 insertions(+), 27 deletions(-) Changeset truncated at 500 lines: diff --git a/source4/heimdal/lib/krb5/pac.c b/source4/heimdal/lib/krb5/pac.c index f4caadd..91f68d5 100644 --- a/source4/heimdal/lib/krb5/pac.c +++ b/source4/heimdal/lib/krb5/pac.c @@ -706,7 +706,7 @@ build_logon_name(krb5_context context, krb5_storage *sp; uint64_t t; char *s, *s2; - size_t i, len; + size_t s2_len; t = unix2nttime(authtime); @@ -726,29 +726,60 @@ build_logon_name(krb5_context context, if (ret) goto out; - len = strlen(s); + { + size_t ucs2_len; + uint16_t *ucs2; + unsigned int flags; - CHECK(ret, krb5_store_uint16(sp, len * 2), out); + ret = wind_utf8ucs2_length(s, &ucs2_len); + if (ret) { + free(s); + krb5_set_error_message(context, ret, "Failed to count length of UTF-8 string"); + return ret; + } -#if 1 /* cheat for now */ - s2 = malloc(len * 2); - if (s2 == NULL) { - ret = krb5_enomem(context); + ucs2 = malloc(sizeof(ucs2[0]) * ucs2_len); + if (ucs2 == NULL) { + free(s); + return krb5_enomem(context); + } + + ret = wind_utf8ucs2(s, ucs2, &ucs2_len); free(s); - goto out; - } - for (i = 0; i < len; i++) { - s2[i * 2] = s[i]; - s2[i * 2 + 1] = 0; + if (ret) { + free(ucs2); + krb5_set_error_message(context, ret, "Failed to convert string to UCS-2"); + return ret; + } + + s2_len = (ucs2_len + 1) * 2; + s2 = malloc(s2_len); + if (ucs2 == NULL) { + free(ucs2); + return krb5_enomem(context); + } + + flags = WIND_RW_LE; + ret = wind_ucs2write(ucs2, ucs2_len, + &flags, s2, &s2_len); + free(ucs2); + if (ret) { + free(s2); + krb5_set_error_message(context, ret, "Failed to write to UCS-2 buffer"); + return ret; + } + + /* + * we do not want zero termination + */ + s2_len = ucs2_len * 2; } - free(s); -#else - /* write libwind code here */ -#endif - ret = krb5_storage_write(sp, s2, len * 2); + CHECK(ret, krb5_store_uint16(sp, s2_len), out); + + ret = krb5_storage_write(sp, s2, s2_len); free(s2); - if (ret != (int)(len * 2)) { + if (ret != (int)s2_len) { ret = krb5_enomem(context); goto out; } diff --git a/source4/heimdal/lib/wind/utf8.c b/source4/heimdal/lib/wind/utf8.c index 6907b3c..e1a1eb7 100644 --- a/source4/heimdal/lib/wind/utf8.c +++ b/source4/heimdal/lib/wind/utf8.c @@ -204,13 +204,13 @@ wind_ucs4utf8(const uint32_t *in, size_t in_len, char *out, size_t *out_len) switch(len) { case 4: out[3] = (ch | 0x80) & 0xbf; - ch = ch << 6; + ch = ch >> 6; case 3: out[2] = (ch | 0x80) & 0xbf; - ch = ch << 6; + ch = ch >> 6; case 2: out[1] = (ch | 0x80) & 0xbf; - ch = ch << 6; + ch = ch >> 6; case 1: out[0] = ch | first_char[len - 1]; } @@ -346,8 +346,8 @@ wind_ucs2write(const uint16_t *in, size_t in_len, unsigned int *flags, return WIND_ERR_OVERRUN; if ((*flags) & WIND_RW_LE) { - p[0] = (bom >> 8) & 0xff; - p[1] = (bom ) & 0xff; + p[0] = (bom ) & 0xff; + p[1] = (bom >> 8) & 0xff; } else { p[1] = (bom ) & 0xff; p[0] = (bom >> 8) & 0xff; @@ -360,8 +360,8 @@ wind_ucs2write(const uint16_t *in, size_t in_len, unsigned int *flags, if (len < 2) return WIND_ERR_OVERRUN; if ((*flags) & WIND_RW_LE) { - p[0] = (in[0] >> 8) & 0xff; - p[1] = (in[0] ) & 0xff; + p[0] = (in[0] ) & 0xff; + p[1] = (in[0] >> 8) & 0xff; } else { p[1] = (in[0] ) & 0xff; p[0] = (in[0] >> 8) & 0xff; @@ -479,10 +479,10 @@ wind_ucs2utf8(const uint16_t *in, size_t in_len, char *out, size_t *out_len) switch(len) { case 3: out[2] = (ch | 0x80) & 0xbf; - ch = ch << 6; + ch = ch >> 6; case 2: out[1] = (ch | 0x80) & 0xbf; - ch = ch << 6; + ch = ch >> 6; case 1: out[0] = ch | first_char[len - 1]; } diff --git a/source4/heimdal/lib/wind/version-script.map b/source4/heimdal/lib/wind/version-script.map index a6ca3ae..6b5abb5 100644 --- a/source4/heimdal/lib/wind/version-script.map +++ b/source4/heimdal/lib/wind/version-script.map @@ -14,6 +14,7 @@ HEIMDAL_WIND_1.0 { wind_utf8ucs2_length; wind_ucs2utf8_length; wind_ucs2read; + wind_ucs2write; # testing _wind_combining_class; _wind_stringprep_testbidi; -- Samba Shared Repository