Skip to content

Commit 877722c

Browse files
Pranav GoyalGitHub Enterprise
authored andcommitted
Merge pull request #986 from mq-cloudpak/pranav-4562-c-sast-sc2
Zero sensitive memory before freeing credentials
2 parents 3693e10 + 07e9864 commit 877722c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

authservice/mqsimpleauth/src/mqsimpleauth.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static void MQENTRY mqsimpleauth_authenticate_user_csp(
141141
*pReason = MQRC_SERVICE_ERROR;
142142
if (csp_user)
143143
{
144+
memset(csp_user, 0, pSecurityParms->CSPUserIdLength);
144145
free(csp_user);
145146
}
146147
return;
@@ -200,10 +201,12 @@ static void MQENTRY mqsimpleauth_authenticate_user_csp(
200201
}
201202
if (csp_user)
202203
{
204+
memset(csp_user, 0, pSecurityParms->CSPUserIdLength);
203205
free(csp_user);
204206
}
205207
if (csp_pass)
206208
{
209+
memset(csp_pass, 0, pSecurityParms->CSPPasswordLength);
207210
free(csp_pass);
208211
}
209212
return;
@@ -286,6 +289,7 @@ static void MQENTRY mqsimpleauth_authenticate_user(
286289
}
287290
if (spuser)
288291
{
292+
memset(spuser, 0, sizeof(PMQCHAR12) + 1);
289293
free(spuser);
290294
}
291295
}

0 commit comments

Comments
 (0)