Modifications to resolve issues found during self-code review.
This commit is contained in:
@@ -94,10 +94,25 @@ pam_sm_authenticate(pam_handle_t *pamh,
|
||||
char *pServicename = NULL;
|
||||
char *pAuthToken = NULL;
|
||||
|
||||
// Verify input parameters
|
||||
if (pamh == NULL
|
||||
|| (argc > 0 && argv == NULL))
|
||||
{
|
||||
LogError("Invalid parameter detected");
|
||||
return PAM_SYSTEM_ERR;
|
||||
}
|
||||
|
||||
// Determine if we are supposed to perform the username check
|
||||
// based on the arguments specified.
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
// Do safety check
|
||||
if (argv[i] == NULL)
|
||||
{
|
||||
LogError("Invalid parameter detected");
|
||||
return PAM_SYSTEM_ERR;
|
||||
}
|
||||
|
||||
if (*(argv[i]) == 'U')
|
||||
{
|
||||
// The arguments indicate that we should check the username
|
||||
@@ -116,7 +131,7 @@ pam_sm_authenticate(pam_handle_t *pamh,
|
||||
// the username check.
|
||||
if (performUsernameCheck)
|
||||
{
|
||||
char *pUsername;
|
||||
char *pUsername = NULL;
|
||||
struct pam_response *responses = NULL;
|
||||
|
||||
// Obtain the username so that it can be checked.
|
||||
@@ -135,11 +150,12 @@ pam_sm_authenticate(pam_handle_t *pamh,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct pam_conv *pConv;
|
||||
struct pam_conv *pConv = NULL;
|
||||
|
||||
// The username has not been set, try to obtain it from the
|
||||
// application through the use of the conversation function.
|
||||
if (pam_get_item(pamh, PAM_CONV, (void*) &pConv) == PAM_SUCCESS)
|
||||
if (pam_get_item(pamh, PAM_CONV, (void*) &pConv) == PAM_SUCCESS
|
||||
&& pConv != NULL)
|
||||
{
|
||||
struct pam_message msg;
|
||||
struct pam_message *messages = &msg;
|
||||
@@ -150,7 +166,8 @@ pam_sm_authenticate(pam_handle_t *pamh,
|
||||
if (pConv->conv(1,
|
||||
(const struct pam_message **) &messages,
|
||||
&responses,
|
||||
pConv->appdata_ptr) == PAM_SUCCESS)
|
||||
pConv->appdata_ptr) == PAM_SUCCESS
|
||||
&& responses != NULL)
|
||||
{
|
||||
// Check if we have a successful response
|
||||
if (responses[0].resp_retcode == PAM_SUCCESS
|
||||
@@ -216,7 +233,8 @@ pam_sm_authenticate(pam_handle_t *pamh,
|
||||
if (pConv->conv(1,
|
||||
(const struct pam_message **) &messages,
|
||||
&responses,
|
||||
pConv->appdata_ptr) == PAM_SUCCESS)
|
||||
pConv->appdata_ptr) == PAM_SUCCESS
|
||||
&& responses != NULL)
|
||||
{
|
||||
// Check if we have a successful response
|
||||
if (responses[0].resp_retcode == PAM_SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user