FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(message): prevent segfault on invalid UTF-8 by meshchellomishel · Pull Request #624 · python-ldap/python-ldap · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 19 additions & 0 deletions Modules/message.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ LDAPmessage_to_python(LDAP *ld, LDAPMessage *m, int add_ctrls,
struct berval **bvals;

pyattr = PyUnicode_FromString(attr);
if (pyattr == NULL) {
Py_DECREF(attrdict);
Py_DECREF(result);
if (ber != NULL)
ber_free(ber, 0);
ldap_msgfree(m);
ldap_memfree(attr);
ldap_memfree(dn);
Py_XDECREF(pyctrls);
return NULL;
}

bvals = ldap_get_values_len(ld, entry, attr);

Expand Down Expand Up @@ -217,6 +228,14 @@ LDAPmessage_to_python(LDAP *ld, LDAPMessage *m, int add_ctrls,
for (i = 0; refs[i] != NULL; i++) {
/* A referal is a distinguishedName => unicode */
PyObject *refstr = PyUnicode_FromString(refs[i]);
if (refstr == NULL) {
Py_DECREF(reflist);
Py_DECREF(result);
ber_memvfree((void **)refs);
ldap_msgfree(m);
Py_XDECREF(pyctrls);
return NULL;
}

PyList_Append(reflist, refstr);
Py_DECREF(refstr);
Expand Down
Loading

Back | FazBrowse Home | New Git URL