Memory leaks?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've just started to implement PAM support in my application.
All works well, but looks like I have some memory leaks.

This is a very simplified version of the code to demonstrate the issue:

#include <security/pam_appl.h>
#include <stdio.h>

static int misc_conv(int num_msg,
            const struct pam_message **msg,
            struct pam_response **resp,
            void *appdata_ptr)
{
 return PAM_CONV_ERR;
}

static int auth(char *service, char *user, char *password)
{
 int retval;
 struct pam_conv conv = {
   misc_conv,
   password
 };
 pam_handle_t *pamh = NULL;
 retval = pam_start(service, user, &conv, &pamh);
 if (retval == PAM_SUCCESS)
   retval = pam_authenticate(pamh, 0);
 printf("%s\n", pam_strerror(pamh, retval));
 pam_end(pamh, retval);
 return retval;
}

int main(int argc, char *argv[])
{
 if (argc != 4)
 {
   printf("Usage: %s service user password\n", argv[0]);
   return 1;
 }
 char *service = argv[1];
 char *user = argv[2];
 char *password = argv[3];
 for (;;) auth(service, user, password);
 return 0;
}

As you can see I don't use malloc/calloc here. However, the memory is leaking and valgrind shows this (451 bytes per iteration in my case). The doc says that it is the caller's responsibility to release the responses, but I just can't understand where should I free() it.
Could you point me to my fault?

_______________________________________________
Pam-list mailing list
Pam-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/pam-list

[Index of Archives]     [Fedora Users]     [Kernel]     [Red Hat Install]     [Linux for the blind]     [Gimp]

  Powered by Linux