This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Possible missing NULL check in pyexpat
Type: crash Stage: resolved
Components: Extension Modules Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexc, gregory.p.smith, serhiy.storchaka
Priority: normal Keywords: easy (C)

Created on 2017-03-01 05:54 by alexc, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 573 merged svelankar, 2017-03-09 05:07
Messages (2)
msg288739 - (view) Author: Alex CHEN (alexc) Date: 2017-03-01 05:54
Hi,

Our tool reported a position that doesn't check for returned value (from a function that might returns null). might need a look that is there any problem or I am missing something.

in function PyUnknownEncodingHandler of file pyexpat.c,

    if (namespace_separator != NULL) {
        self->itself = XML_ParserCreateNS(encoding, *namespace_separator);
    }
    else {
        self->itself = XML_ParserCreate(encoding);           // could XML_ParserCreate returns null in this point?
    }
.....
    XML_SetHashSalt(self->itself,                             // if it does return null, null pointer will passed into XML_SetHashSalt and will be dereferenced.
                    (unsigned long)_Py_HashSecret.prefix);    
#endif
msg289272 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-09 05:34
Thank you Alex and svelankar for your report and fix.
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73868
2017-03-09 05:34:50serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg289272

stage: needs patch -> resolved
2017-03-09 05:07:52svelankarsetpull_requests: + pull_request469
2017-03-02 18:57:10brett.cannonsettitle: Checks for null return value -> Possible missing NULL check in pyexpat
2017-03-01 06:25:08serhiy.storchakasetnosy: + gregory.p.smith, serhiy.storchaka
components: + Extension Modules
keywords: + easy (C)
type: crash
stage: needs patch
2017-03-01 05:54:36alexccreate