0002-nofree.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. [PATCH] deallocate the conversation response only in case of error
  2. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=679714
  3. Downloaded from:
  4. http://pkgs.fedoraproject.org/cgit/PyPAM.git/plain/PyPAM-0.5.0-nofree.patch
  5. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  6. diff --git a/PAMmodule.c b/PAMmodule.c
  7. index 03cb799..a7ff8a5 100644
  8. --- a/PAMmodule.c
  9. +++ b/PAMmodule.c
  10. @@ -24,8 +24,6 @@ typedef struct {
  11. char *service;
  12. char *user;
  13. PyObject *callback;
  14. - struct pam_response *response_data;
  15. - int response_len;
  16. PyObject *user_data;
  17. void *dlh1, *dlh2;
  18. } PyPAMObject;
  19. @@ -54,15 +52,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
  20. Py_INCREF(self);
  21. - if (NULL != self->response_data) {
  22. - for (int i = 0; i < self->response_len; i++) {
  23. - free(self->response_data[0].resp);
  24. - }
  25. - free(self->response_data);
  26. - self->response_data = NULL;
  27. - self->response_len = 0;
  28. - }
  29. -
  30. PyObject* msgList = PyList_New(num_msg);
  31. for (int i = 0; i < num_msg; i++) {
  32. @@ -92,6 +81,10 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
  33. char* resp_text;
  34. int resp_retcode = 0;
  35. if (!PyArg_ParseTuple(respTuple, "si", &resp_text, &resp_retcode)) {
  36. + while (i > 0) {
  37. + free((--spr)->resp);
  38. + --i;
  39. + }
  40. free(*resp);
  41. Py_DECREF(respList);
  42. return PAM_CONV_ERR;
  43. @@ -100,10 +93,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg,
  44. spr->resp_retcode = resp_retcode;
  45. Py_DECREF(respTuple);
  46. }
  47. -
  48. - // Save this so we can free it later.
  49. - self->response_data = *resp;
  50. - self->response_len = PyList_Size(respList);
  51. Py_DECREF(respList);
  52. @@ -144,8 +133,6 @@ static PyObject * PyPAM_pam(PyObject *self, PyObject *args)
  53. p->user = NULL;
  54. Py_INCREF(Py_None);
  55. p->callback = Py_None;
  56. - p->response_data = NULL;
  57. - p->response_len = 0;
  58. Py_INCREF(Py_None);
  59. p->user_data = Py_None;