From: "cron2 (Code Review)" cron2 sub=
mitted this change.iservice: rename one_glyph to glyph_size
=
Throughout the function variables which deal with byte counts have a
_si=
ze postfix. one_glyph is the number of bytes in one character.
Reading t=
he code is easier and more consistent this way.
Change-Id: I69a6ab59=
d995fb4a511f57c8535b5ffa4048673c
Signed-off-by: Heiko Hund <heiko@...493...=
2662...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit URL=
: https://gerrit.openvpn.net/c/openvpn/+/1398
Message-Id: <2025112417=
0055.16034-1-gert@...1296...>
URL: https://www.mail-archive.com/openv=
pn-devel@lists.sourceforge.net/msg34642.html
Signed-off-by: Gert Doering=
<gert@...1296...>
---
M src/openvpnserv/interactive.c
1 fil=
e changed, 12 insertions(+), 12 deletions(-)
index 13e303a..220c042 100644
--- a/src/=
openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive=
.c
@@ -2156,14 +2156,14 @@
const DWO=
RD buf_size =3D *size;
=
- const size_t one_glyph =3D sizeof(*domains);
+ const size_t glyph_size =3D sizeof(*domai=
ns);
PWSTR values[] =3D { L"SearchList", L&q=
uot;Domain", L"DhcpDomainSearchList", L"DhcpDomain"=
;, NULL };
for (int i =3D 0; values[=
i]; i++)
{
*size =3D buf_size=
;
err =3D RegGetValueW(itf, NULL, values[i], RRF_R=
T_REG_SZ, NULL, (PBYTE)domains, size);
- if (!err && *size > one_glyph &&=
; domains[(*size / one_glyph) - 1] =3D=3D '\0' && wcschr(do=
mains, '.'))
=
+ if (!err && *size > glyph_size && domains[(*siz=
e / glyph_size) - 1] =3D=3D '\0' && wcschr(domains, '.&=
#39;))
{
/*
* Found domain(s), now convert them:
@=
@ -2171,7 +2171,7 @@
* - convert comma sepa=
rated list to MULTI_SZ
*/
=
PWCHAR pos =3D domains;
- const DWORD buf_len =3D buf_size / one_glyph;
+ const DWORD b=
uf_len =3D buf_size / glyph_size;
while (TRUE)=
{
/* Termina=
te the domain at the next comma */
@@ -2182,8 +2182,8 @@
}
=
size_t domain_len =3D wcslen(pos);
- size_t domain_size =3D domain_len * o=
ne_glyph;
- =
size_t converted_size =3D (pos - domains) * one_glyph;
+ size_t domain_size =
=3D domain_len * glyph_size;
+ size_t converted_size =3D (pos - domains) * glyph_=
size;
/* Ignore itf doma=
ins which match a pushed search domain */
=
if (ListContainsDomain(search_domains, pos, domain_len))
@@=
-2192,7 +2192,7 @@
{
=
/* Overwrite the ignored domain with remaining one=
(s) */
memmove(pos, comma + 1, buf=
_size - converted_size);
- *size -=3D domain_size + one_glyph;+ *size -=
=3D domain_size + glyph_size;
cont=
inue;
}
=
else
@@ -2206,31 +2206,31 @@
/* Add space for the leading dot */
<=
span> domain_len +=3D 1;
- domain_size +=3D one_glyph;+ domain_size +=3D=
glyph_size;
/* Space fo=
r the terminating zeros */
- size_t extra_size =3D 2 * one_glyph;
+ size_t extra_size =3D=
2 * glyph_size;
/* Chec=
k for enough space to convert this domain */
=
if (converted_size + domain_size + extra_size > buf_size)
<=
span> {
/* Domain does=
n't fit, bad luck if it's the first one */
=
*pos =3D '\0';
- *size =3D converted_size =3D=3D 0 ? 0 : c=
onverted_size + one_glyph;
+ *size =3D converted_size =3D=3D 0 ? 0 : converte=
d_size + glyph_size;
return ERROR_MORE=
_DATA;
}
/* Prefix domain at pos with the dot */
- memmove(pos + 1, pos, b=
uf_size - converted_size - one_glyph);
+ memmove(pos + 1, pos, buf_size - convert=
ed_size - glyph_size);
domains[buf_len - 1=
] =3D '\0';
*pos =3D '.';<=
/span>
- *size =
+=3D one_glyph;
+ =
*size +=3D glyph_size;
=
if (!comma)
{
=
/* Conversion is done */
=
*(pos + domain_len) =3D '\0';
- *size +=3D one_glyph;
=
+ *size +=3D=
glyph_size;
return NO_ERROR; }
To view, visit change 1398. To unsubscribe, or for help writing mail filt= ers, visit setti= ngs.