Skip to contentSkip to conversation

Patch for plugin/auth-pam.c

Openvpn-devel Daniel Johnson 2 participants 3 messages Dec 13, 2009 – Mar 30, 2010

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 12 lines · David Sommerseth

- - const char *return_value = NULL;
+ aresp[i].resp = NULL;

This I didn't think about, but I saw another potential leak. However, your idea here is clever! But I would probably suggest:

      if( aresp[i].resp ) {
              free(aresp[i].resp);
              aresp[i].resp = NULL;
      }
Quoted 4 lines

But! The potential culprit here is if the aresp[i] struct is not zeroed before usage. If it is not and this pointer is pointing at something it do not own, your patch is definitely more the correct approach.

It was already nulled at post-patch line 558. I think that the additional NULLing makes the code more readable but strictly speaking it is not necessary.

Daniel Johnson
[email protected]...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkslSP8ACgkQ6vGcUBY+ge+69gCgwHLbuJsf03uuWXTbP9iI0r9a RdAAn13l4KIRFa1WR38lDWs3SHu3iJxU
=5kly
-----END PGP SIGNATURE-----

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 13 lines · Daniel Johnson
Quoted 11 lines · David Sommerseth

- - const char *return_value = NULL;
+ aresp[i].resp = NULL;

This I didn't think about, but I saw another potential leak. However, your idea here is clever! But I would probably suggest:

      if( aresp[i].resp ) {
              free(aresp[i].resp);
              aresp[i].resp = NULL;
      }
Quoted 8 lines
Quoted 4 lines

But! The potential culprit here is if the aresp[i] struct is not zeroed before usage. If it is not and this pointer is pointing at something it do not own, your patch is definitely more the correct approach.

It was already nulled at post-patch line 558. I think that the additional NULLing makes the code more readable but strictly speaking it is not necessary.

Yes, you are right. It's calloc'ed earlier in my_conv(). I just double checked the whole code now (I just looked at the patch itself earlier today).

I'd say this patch is ready for some real testing now, possibly worth considering for inclusion to the next development tree. I find it valuable to include it at least.

One thing, which is a little bit of a mystery for me, is how the PAM layer treats the whole aresp array pointer and the memory allocated there. I don't know the PAM implementation good enough to see if it does any freeing of the allocated memory elsewhere. This could be a second place where memory leaks are found. But to fix this, a bigger rewrite would be needed. And to be honest, this patch should not fix that. That's another patch.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkslczwACgkQDC186MBRfrrHpgCeLfKriodtHz2Cbh4VDFyBuJMz mfAAn3+kUBwLWzIwSeOuZVUvuxiEpadS
=33Kf
-----END PGP SIGNATURE-----

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 23 lines · David Sommerseth
Quoted 13 lines · Daniel Johnson
Quoted 11 lines · David Sommerseth

- - const char *return_value = NULL;
+ aresp[i].resp = NULL;

This I didn't think about, but I saw another potential leak. However, your idea here is clever! But I would probably suggest:

      if( aresp[i].resp ) {
              free(aresp[i].resp);
              aresp[i].resp = NULL;
      }
Quoted 8 lines
Quoted 4 lines

But! The potential culprit here is if the aresp[i] struct is not zeroed before usage. If it is not and this pointer is pointing at something it do not own, your patch is definitely more the correct approach.

It was already nulled at post-patch line 558. I think that the additional NULLing makes the code more readable but strictly speaking it is not necessary.

Quoted 7 lines

Yes, you are right. It's calloc'ed earlier in my_conv(). I just double checked the whole code now (I just looked at the patch itself earlier today).

I'd say this patch is ready for some real testing now, possibly worth considering for inclusion to the next development tree. I find it valuable to include it at least.

Hi,

Just wanted to inform that this patch has been included into the bugfix2.1 branch in the openvpn-testing.git tree. It will be merged into the 'allmerged' branch soon when more patches are ready.

commit 0439701630e257d7abf0e58c204210a6459307da
<http://openvpn.git.sourceforge.net/git/gitweb.cgi?p=openvpn/openvpn-testing.git;a=commitdiff;h=0439701630e257d7abf0e58c204210a6459307da>

Thank you very much, and I'm sorry about the delay getting it in.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkuyA70ACgkQDC186MBRfrqhYQCfbh8RjV+tFgrw0JnvYadMOqkE uE4AnjZyD1w2lmBf0UKc3e5e523A51lv
=uGsN
-----END PGP SIGNATURE-----