Skip to content

Commit 3bdac8c

Browse files
committed
in_winevtlog: Use different variables for collecting each of lengths
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 9939213 commit 3bdac8c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

plugins/in_winevtlog/pack.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ static int sid_to_utf8(struct winevtlog_config *ctx, PSID sid,
530530
{
531531
#define MAX_NAME 256
532532
LPWSTR wide_sid = NULL;
533-
DWORD len = MAX_NAME, err = ERROR_SUCCESS;
533+
DWORD acct_len = MAX_NAME, domain_len = MAX_NAME;
534+
DWORD err = ERROR_SUCCESS;
534535
SID_NAME_USE sid_type = SidTypeUnknown;
535536
char account[MAX_NAME];
536537
char domain[MAX_NAME];
@@ -555,7 +556,9 @@ static int sid_to_utf8(struct winevtlog_config *ctx, PSID sid,
555556

556557
/* Skip friendly-name resolution for capability SIDs */
557558
if (wcsnicmp(wide_sid, L"S-1-15-3-", 9) != 0) {
558-
if (LookupAccountSidA(NULL, sid, account, &len, domain, &len, &sid_type)) {
559+
if (LookupAccountSidA(NULL, sid,
560+
account, &acct_len, domain,
561+
&domain_len, &sid_type)) {
559562
_snprintf_s(formatted, sizeof(formatted), _TRUNCATE, "%s\\%s", domain, account);
560563
formatted_len = strlen(formatted);
561564
if (formatted_len > 0) {
@@ -628,7 +631,8 @@ static int pack_sid(struct winevtlog_config *ctx, PSID sid, int extract_sid)
628631
#define MAX_NAME 256
629632
size_t size;
630633
LPWSTR wide_sid = NULL;
631-
DWORD len = MAX_NAME, err = ERROR_SUCCESS;
634+
DWORD acct_len = MAX_NAME, domain_len = MAX_NAME;
635+
DWORD err = ERROR_SUCCESS;
632636
int ret = -1;
633637
SID_NAME_USE sid_type = SidTypeUnknown;
634638
char account[MAX_NAME];
@@ -649,8 +653,8 @@ static int pack_sid(struct winevtlog_config *ctx, PSID sid, int extract_sid)
649653
goto not_mapped_error;
650654
}
651655
if (!LookupAccountSidA(NULL, sid,
652-
account, &len, domain,
653-
&len, &sid_type)) {
656+
account, &acct_len, domain,
657+
&domain_len, &sid_type)) {
654658
err = GetLastError();
655659
if (err == ERROR_NONE_MAPPED) {
656660
flb_plg_debug(ctx->ins, "AccountSid is not mapped. code: %u", err);

0 commit comments

Comments
 (0)