This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: "regtool -m set" writes 2 extra bytes at the end
- From: Christopher Faylor <cygwin-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Sat, 30 Oct 2010 21:42:35 -0400
- Subject: Re: "regtool -m set" writes 2 extra bytes at the end
- References: <20101031003731.GA30070@dpotapov.dyndns.org>
- Reply-to: cygwin-patches at cygwin dot com
[Apologies for previously sending this as private email. Don't know how
that happened]
On Sun, Oct 31, 2010 at 03:37:31AM +0300, Dmitry Potapov wrote:
>Hi,
>
>The easiest way to demonstrate the problem is to run the following shell
>script:
>
>---- >8 ---
>regtool -m set /HKEY_LOCAL_MACHINE/SOFTWARE/Test 1234
>expected="31 00 32 00 33 00 34 00 00 00 00 00"
>actual="`regtool get -b /HKEY_LOCAL_MACHINE/SOFTWARE/Test`"
>
>if [ "$actual" != "$expected" ]; then
> echo FAILED
>else
> echo OK
>fi
>---- >8 ---
I've checked this in but isn't there one too many trailing "00 00"s in
the above, i.e., shouldn't it be "n" rather than "n + 1"?
>The patch is below.
Thanks for the patch.
cgf
>
>--- >8 ---
>Index: regtool.cc
>===================================================================
>RCS file: /cvs/src/src/winsup/utils/regtool.cc,v
>retrieving revision 1.30
>diff -u -r1.30 regtool.cc
>--- regtool.cc 28 Aug 2010 11:22:37 -0000 1.30
>+++ regtool.cc 30 Oct 2010 22:56:47 -0000
>@@ -711,7 +711,7 @@
> n += mbstowcs ((wchar_t *) data + n, argv[i], max_n - n) + 1;
> ((wchar_t *)data)[n] = L'\0';
> rv = RegSetValueExW (key, value, 0, REG_MULTI_SZ, (const BYTE *) data,
>- (max_n + 1) * sizeof (wchar_t));
>+ (n + 1) * sizeof (wchar_t));
> break;
> case REG_AUTO:
> rv = ERROR_SUCCESS;
>--- >8 ---
>
>
>Dmitry
>