Skip to content

Commit

Permalink
Use a more natural way of returning the "item" pointer
Browse files Browse the repository at this point in the history
Author: Eric Haszlakiewicz <[email protected]>
  • Loading branch information
ThomasHabets committed May 13, 2016
1 parent 3da2d67 commit feb2d82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions libpam/examples/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ int pam_get_item(const pam_handle_t *pamh, int item_type,
switch (item_type) {
case PAM_SERVICE: {
static const char service[] = "google_authenticator_demo";
memcpy(item, &service, sizeof(&service));
*item = service;
return PAM_SUCCESS;
}
case PAM_USER: {
char *user = getenv("USER");
memcpy(item, &user, sizeof(&user));
*item = user;
return PAM_SUCCESS;
}
case PAM_CONV: {
static struct pam_conv conv = { .conv = conversation }, *p_conv = &conv;
memcpy(item, &p_conv, sizeof(p_conv));
*item = p_conv;
return PAM_SUCCESS;
}
default:
Expand Down
6 changes: 3 additions & 3 deletions libpam/tests/pam_google_authenticator_unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ int pam_get_item(const pam_handle_t *pamh, int item_type,
switch (item_type) {
case PAM_SERVICE: {
static const char *service = "google_authenticator_unittest";
memcpy(item, &service, sizeof(&service));
*item = service;
return PAM_SUCCESS;
}
case PAM_USER: {
char *user = getenv("USER");
memcpy(item, &user, sizeof(&user));
*item = user;
return PAM_SUCCESS;
}
case PAM_CONV: {
static struct pam_conv conv = { .conv = conversation }, *p_conv = &conv;
memcpy(item, &p_conv, sizeof(p_conv));
*item = p_conv;
return PAM_SUCCESS;
}
case PAM_AUTHTOK: {
Expand Down

0 comments on commit feb2d82

Please sign in to comment.