svn commit: samba r23668 - in branches: SAMBA_3_0/source/lib
SAMBA_3_0_26/source/lib
obnox at samba.org
obnox at samba.org
Sat Jun 30 23:52:24 GMT 2007
Author: obnox
Date: 2007-06-30 23:52:23 +0000 (Sat, 30 Jun 2007)
New Revision: 23668
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23668
Log:
When creating a new string value, win2k regedit delivers
one byte of data despite characters being two-byte.
This modifies registry_pull_value, to change the data
to the correct two-byte version of the empty string,
(as delivered by winxp), when only one byte of data is
received.
Michael
Modified:
branches/SAMBA_3_0/source/lib/util_reg_api.c
branches/SAMBA_3_0_26/source/lib/util_reg_api.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/util_reg_api.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util_reg_api.c 2007-06-30 22:31:13 UTC (rev 23667)
+++ branches/SAMBA_3_0/source/lib/util_reg_api.c 2007-06-30 23:52:23 UTC (rev 23668)
@@ -53,19 +53,33 @@
smb_ucs2_t *tmp;
uint32 num_ucs2 = length / 2;
- if ((length % 2) != 0) {
+ if (length == 1) {
+ /* win2k regedit gives us a string of 1 byte when
+ * creating a new value of type REG_SZ. this workaround
+ * replaces the input by using the same string as
+ * winxp delivers. */
+ length = 2;
+ if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, 2))) {
+ err = WERR_NOMEM;
+ goto error;
+ }
+ tmp[0] = 2;
+ tmp[1] = 0;
+ }
+ else if ((length % 2) != 0) {
err = WERR_INVALID_PARAM;
goto error;
}
+ else {
+ if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, num_ucs2+1))) {
+ err = WERR_NOMEM;
+ goto error;
+ }
- if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, num_ucs2+1))) {
- err = WERR_NOMEM;
- goto error;
+ memcpy((void *)tmp, (const void *)data, length);
+ tmp[num_ucs2] = 0;
}
- memcpy((void *)tmp, (const void *)data, length);
- tmp[num_ucs2] = 0;
-
value->v.sz.len = convert_string_talloc(
value, CH_UTF16LE, CH_UNIX, tmp, length+2,
&value->v.sz.str, False);
Modified: branches/SAMBA_3_0_26/source/lib/util_reg_api.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/util_reg_api.c 2007-06-30 22:31:13 UTC (rev 23667)
+++ branches/SAMBA_3_0_26/source/lib/util_reg_api.c 2007-06-30 23:52:23 UTC (rev 23668)
@@ -53,19 +53,33 @@
smb_ucs2_t *tmp;
uint32 num_ucs2 = length / 2;
- if ((length % 2) != 0) {
+ if (length == 1) {
+ /* win2k regedit gives us a string of 1 byte when
+ * creating a new value of type REG_SZ. this workaround
+ * replaces the input by using the same string as
+ * winxp delivers. */
+ length = 2;
+ if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, 2))) {
+ err = WERR_NOMEM;
+ goto error;
+ }
+ tmp[0] = 2;
+ tmp[1] = 0;
+ }
+ else if ((length % 2) != 0) {
err = WERR_INVALID_PARAM;
goto error;
}
+ else {
+ if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, num_ucs2+1))) {
+ err = WERR_NOMEM;
+ goto error;
+ }
- if (!(tmp = SMB_MALLOC_ARRAY(smb_ucs2_t, num_ucs2+1))) {
- err = WERR_NOMEM;
- goto error;
+ memcpy((void *)tmp, (const void *)data, length);
+ tmp[num_ucs2] = 0;
}
- memcpy((void *)tmp, (const void *)data, length);
- tmp[num_ucs2] = 0;
-
value->v.sz.len = convert_string_talloc(
value, CH_UTF16LE, CH_UNIX, tmp, length+2,
&value->v.sz.str, False);
More information about the samba-cvs
mailing list