4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-03-02 04:55:35 +08:00

* regtool.cc: Extend copyright-years.

(print_version): Ditto.
	(cmd_list): Don't depend on terminating '\0' being present on
	string-values.
	(cmd_get): Don't attempt to read more than present, but keep
	extra space for terminating '\0'. Really output REG_BINARY.
	Don't leak memory.
	(cmd_set): Include trailing '\0' in string's length.
This commit is contained in:
Corinna Vinschen 2005-09-08 09:24:41 +00:00
parent 70d0243ce9
commit b17b7644d5
2 changed files with 19 additions and 7 deletions

View File

@ -1,3 +1,14 @@
2005-09-08 Bas van Gompel <cygwin-patch.buzz@bavag.tmfweb.nl>
* regtool.cc: Extend copyright-years.
(print_version): Ditto.
(cmd_list): Don't depend on terminating '\0' being present on
string-values.
(cmd_get): Don't attempt to read more than present, but keep
extra space for terminating '\0'. Really output REG_BINARY.
Don't leak memory.
(cmd_set): Include trailing '\0' in string's length.
2005-08-18 Corinna Vinschen <corinna@vinschen.de> 2005-08-18 Corinna Vinschen <corinna@vinschen.de>
* passwd.c (longopts): Add --logonserver option. * passwd.c (longopts): Add --logonserver option.

View File

@ -1,6 +1,6 @@
/* regtool.cc /* regtool.cc
Copyright 2000, 2001, 2002, 2003, 2004 Red Hat Inc. Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -138,7 +138,7 @@ print_version ()
printf ("\ printf ("\
%s (cygwin) %.*s\n\ %s (cygwin) %.*s\n\
Registry Tool\n\ Registry Tool\n\
Copyright 2000, 2001, 2002 Red Hat, Inc.\n\ Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.\n\
Compiled on %s\n\ Compiled on %s\n\
", prog_name, len, v, __DATE__); ", prog_name, len, v, __DATE__);
} }
@ -398,6 +398,7 @@ cmd_list ()
m = maxvalnamelen + 1; m = maxvalnamelen + 1;
n = maxvaluelen + 1; n = maxvaluelen + 1;
RegEnumValue (key, i, value_name, &m, 0, &t, (BYTE *) value_data, &n); RegEnumValue (key, i, value_name, &m, 0, &t, (BYTE *) value_data, &n);
value_data[n] = 0;
if (!verbose) if (!verbose)
printf ("%s\n", value_name); printf ("%s\n", value_name);
else else
@ -515,11 +516,11 @@ cmd_set ()
sizeof (v)); sizeof (v));
break; break;
case KT_STRING: case KT_STRING:
rv = RegSetValueEx (key, value, 0, REG_SZ, (const BYTE *) a, strlen (a)); rv = RegSetValueEx (key, value, 0, REG_SZ, (const BYTE *) a, strlen (a) + 1);
break; break;
case KT_EXPAND: case KT_EXPAND:
rv = RegSetValueEx (key, value, 0, REG_EXPAND_SZ, (const BYTE *) a, rv = RegSetValueEx (key, value, 0, REG_EXPAND_SZ, (const BYTE *) a,
strlen (a)); strlen (a) + 1);
break; break;
case KT_MULTI: case KT_MULTI:
for (i = 1, n = 1; argv[i]; i++) for (i = 1, n = 1; argv[i]; i++)
@ -569,15 +570,14 @@ cmd_get ()
rv = RegQueryValueEx (key, value, 0, &vtype, 0, &dsize); rv = RegQueryValueEx (key, value, 0, &vtype, 0, &dsize);
if (rv != ERROR_SUCCESS) if (rv != ERROR_SUCCESS)
Fail (rv); Fail (rv);
dsize++; data = (char *) malloc (dsize + 1);
data = (char *) malloc (dsize);
rv = RegQueryValueEx (key, value, 0, &vtype, (BYTE *) data, &dsize); rv = RegQueryValueEx (key, value, 0, &vtype, (BYTE *) data, &dsize);
if (rv != ERROR_SUCCESS) if (rv != ERROR_SUCCESS)
Fail (rv); Fail (rv);
switch (vtype) switch (vtype)
{ {
case REG_BINARY: case REG_BINARY:
fwrite (data, dsize, 0, stdout); fwrite (data, dsize, 1, stdout);
break; break;
case REG_DWORD: case REG_DWORD:
printf ("%lu\n", *(DWORD *) data); printf ("%lu\n", *(DWORD *) data);
@ -593,6 +593,7 @@ cmd_get ()
bufsize = ExpandEnvironmentStrings (data, 0, 0); bufsize = ExpandEnvironmentStrings (data, 0, 0);
buf = (char *) malloc (bufsize + 1); buf = (char *) malloc (bufsize + 1);
ExpandEnvironmentStrings (data, buf, bufsize + 1); ExpandEnvironmentStrings (data, buf, bufsize + 1);
free (data);
data = buf; data = buf;
} }
printf ("%s\n", data); printf ("%s\n", data);