Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
09a785cb
Commit
09a785cb
authored
Sep 26, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Fix formatted output length for base64.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5652a191
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
8 deletions
+28
-8
base64.c
dlls/crypt32/base64.c
+6
-4
base64.c
dlls/crypt32/tests/base64.c
+22
-4
No files found.
dlls/crypt32/base64.c
View file @
09a785cb
...
...
@@ -104,8 +104,9 @@ static LONG encodeBase64A(const BYTE *in_buf, int in_len, LPCSTR sep,
LPSTR
ptr
;
TRACE
(
"bytes is %d, pad bytes is %d
\n
"
,
bytes
,
pad_bytes
);
needed
=
bytes
+
pad_bytes
+
1
;
needed
+=
(
needed
/
64
+
1
)
*
strlen
(
sep
);
needed
=
bytes
+
pad_bytes
;
needed
+=
(
needed
/
64
+
(
needed
%
64
?
1
:
0
))
*
strlen
(
sep
);
needed
++
;
if
(
needed
>
*
out_len
)
{
...
...
@@ -303,8 +304,9 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep,
LPWSTR
ptr
;
TRACE
(
"bytes is %d, pad bytes is %d
\n
"
,
bytes
,
pad_bytes
);
needed
=
bytes
+
pad_bytes
+
1
;
needed
+=
(
needed
/
64
+
1
)
*
strlenW
(
sep
);
needed
=
bytes
+
pad_bytes
;
needed
+=
(
needed
/
64
+
(
needed
%
64
?
1
:
0
))
*
strlenW
(
sep
);
needed
++
;
if
(
needed
>
*
out_len
)
{
...
...
dlls/crypt32/tests/base64.c
View file @
09a785cb
...
...
@@ -55,6 +55,8 @@ static const BYTE toEncode4[] =
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
;
static
const
BYTE
toEncode5
[]
=
"abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHI"
;
static
const
struct
BinTests
tests
[]
=
{
{
toEncode1
,
sizeof
(
toEncode1
),
"AA==
\r\n
"
,
},
...
...
@@ -66,6 +68,8 @@ static const struct BinTests tests[] = {
"d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2
\r\n
"
"Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH
\r\n
"
"SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==
\r\n
"
},
{
toEncode5
,
sizeof
(
toEncode5
),
"YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=
\r\n
"
},
};
static
const
struct
BinTests
testsNoCR
[]
=
{
...
...
@@ -78,6 +82,8 @@ static const struct BinTests testsNoCR[] = {
"d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2
\n
"
"Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH
\n
"
"SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==
\n
"
},
{
toEncode5
,
sizeof
(
toEncode5
),
"YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=
\n
"
},
};
static
WCHAR
*
strdupAtoW
(
const
char
*
str
)
...
...
@@ -96,15 +102,21 @@ static WCHAR *strdupAtoW(const char *str)
static
void
encodeAndCompareBase64_A
(
const
BYTE
*
toEncode
,
DWORD
toEncodeLen
,
DWORD
format
,
const
char
*
expected
,
const
char
*
header
,
const
char
*
trailer
)
{
DWORD
strLen
,
strLen2
;
DWORD
strLen
,
strLen2
,
required
;
const
char
*
ptr
;
LPSTR
str
=
NULL
;
BOOL
ret
;
required
=
strlen
(
expected
)
+
1
;
if
(
header
)
required
+=
strlen
(
header
);
if
(
trailer
)
required
+=
strlen
(
trailer
);
strLen
=
0
;
ret
=
CryptBinaryToStringA
(
toEncode
,
toEncodeLen
,
format
,
NULL
,
&
strLen
);
ok
(
ret
,
"CryptBinaryToStringA failed: %d
\n
"
,
GetLastError
());
ok
(
strLen
>
0
,
"Unexpected required length.
\n
"
);
ok
(
strLen
==
required
,
"Unexpected required length %u, expected %u.
\n
"
,
required
,
strLen
);
strLen2
=
strLen
;
ret
=
CryptBinaryToStringA
(
toEncode
,
toEncodeLen
,
format
,
NULL
,
&
strLen2
);
...
...
@@ -154,16 +166,22 @@ todo_wine {
static
void
encode_compare_base64_W
(
const
BYTE
*
toEncode
,
DWORD
toEncodeLen
,
DWORD
format
,
const
WCHAR
*
expected
,
const
char
*
header
,
const
char
*
trailer
)
{
WCHAR
*
headerW
,
*
trailerW
;
WCHAR
*
headerW
,
*
trailerW
,
required
;
DWORD
strLen
,
strLen2
;
WCHAR
*
strW
=
NULL
;
const
WCHAR
*
ptr
;
BOOL
ret
;
required
=
lstrlenW
(
expected
)
+
1
;
if
(
header
)
required
+=
strlen
(
header
);
if
(
trailer
)
required
+=
strlen
(
trailer
);
strLen
=
0
;
ret
=
CryptBinaryToStringW
(
toEncode
,
toEncodeLen
,
format
,
NULL
,
&
strLen
);
ok
(
ret
,
"CryptBinaryToStringW failed: %d
\n
"
,
GetLastError
());
ok
(
strLen
>
0
,
"Unexpected required length.
\n
"
);
ok
(
strLen
==
required
,
"Unexpected required length %u, expected %u.
\n
"
,
strLen
,
required
);
/* Same call with non-zero length value. */
strLen2
=
strLen
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment