Skip to content

Added 'refList' as a list containing all referrals returned from server. #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Modules/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,18 @@ LDAPraise_for_message(LDAP *l, LDAPMessage *m)
}

if (errnum == LDAP_REFERRAL && refs != NULL && refs[0] != NULL) {
/* Return all referrals as a list in "reflist" */
PyObject *referralList = PyList_New(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check.

int i = 0;
while (refs[i] != NULL) {
PyObject *referralURL = Py_BuildValue("s", refs[i++]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PyUnicode_FromString() and check for error (NULL).

PyList_Append(referralList, referralURL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check.

Py_XDECREF(referralURL);
}
PyDict_SetItemString(info, "reflist", referralList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check

Py_XDECREF(referralList);
/* Keep old behaviour, overshadow error message */
char err[1024];

snprintf(err, sizeof(err), "Referral:\n%s", refs[0]);
str = PyUnicode_FromString(err);
PyDict_SetItemString(info, "info", str);
Expand Down