Skip to content

Commit 77ab4e2

Browse files
committed
patch 8.2.3247: using uninitialized memory when checking for crypt method
Problem: Using uninitialized memory when checking for crypt method. Solution: Check the header length before using the salt and seed.
1 parent 77111e2 commit 77ab4e2

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/fileio.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,15 +2917,16 @@ check_for_cryptkey(
29172917
{
29182918
int header_len;
29192919

2920-
curbuf->b_cryptstate = crypt_create_from_header(
2921-
method, cryptkey, ptr);
2922-
crypt_set_cm_option(curbuf, method);
2923-
2924-
// Remove cryptmethod specific header from the text.
29252920
header_len = crypt_get_header_len(method);
29262921
if (*sizep <= header_len)
29272922
// invalid header, buffer can't be encrypted
29282923
return NULL;
2924+
2925+
curbuf->b_cryptstate = crypt_create_from_header(
2926+
method, cryptkey, ptr);
2927+
crypt_set_cm_option(curbuf, method);
2928+
2929+
// Remove cryptmethod specific header from the text.
29292930
*filesizep += header_len;
29302931
*sizep -= header_len;
29312932
mch_memmove(ptr, ptr + header_len, (size_t)*sizep);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3247,
758760
/**/
759761
3246,
760762
/**/

0 commit comments

Comments
 (0)