[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread miss-islington


miss-islington  added the comment:


New changeset 323a91bb3a2b5639637efc517fe3f30d3bc288e2 by Miss Islington (bot) 
in branch '3.6':
closes bpo-34501: PyType_FromSpecWithBases: Check spec->name before 
dereferencing it. (GH-8930)
https://github.com/python/cpython/commit/323a91bb3a2b5639637efc517fe3f30d3bc288e2


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread miss-islington


miss-islington  added the comment:


New changeset 15dadacabf6a1c62e9920b6a42ff8936ea1830f8 by Miss Islington (bot) 
in branch '3.7':
closes bpo-34501: PyType_FromSpecWithBases: Check spec->name before 
dereferencing it. (GH-8930)
https://github.com/python/cpython/commit/15dadacabf6a1c62e9920b6a42ff8936ea1830f8


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8404

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8403

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 5f79b50763d687aeeed8edcb4efcc7ac9f8fa186 by Benjamin Peterson 
(Alexey Izbyshev) in branch 'master':
closes bpo-34501: PyType_FromSpecWithBases: Check spec->name before 
dereferencing it. (GH-8930)
https://github.com/python/cpython/commit/5f79b50763d687aeeed8edcb4efcc7ac9f8fa186


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread Alexey Izbyshev


Alexey Izbyshev  added the comment:

@enedil It seems that all later check either set a message or simply propagate 
the error set by a called function. Did you mean any specific later check?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread Alexey Izbyshev


Change by Alexey Izbyshev :


--
keywords: +patch
pull_requests: +8402
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread Michał Radwański

Michał Radwański  added the comment:

But if the error message is set, then for consistency, it should be also the 
case that the later checks set some kind of error message.

--
nosy: +enedil

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

Your suggested fix seems fine to me.

--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34501] PyType_FromSpecWithBases: spec->name is dereferenced before checking for NULL

2018-08-25 Thread Alexey Izbyshev


New submission from Alexey Izbyshev :

In the following snippet from PyType_FromSpecWithBases() in 
Objects/typeobject.c, spec->name is dereferenced by strrchr() but then is 
checked for NULL:

/* Set the type name and qualname */
s = strrchr(spec->name, '.');
if (s == NULL)
s = (char*)spec->name;
else
s++;

[snip]

type->tp_name = spec->name;
if (!type->tp_name)
goto fail;

This was reported by Svace static analyzer.

If I were to check spec->name first, what error should I report to the caller? 
Is something like the following OK?

if (spec->name == NULL) {
PyErr_SetString(PyExc_SystemError,
   "Type spec does not define the name field.");
goto fail;
}

--
components: Interpreter Core
messages: 324073
nosy: berker.peksag, izbyshev, serhiy.storchaka
priority: normal
severity: normal
status: open
title: PyType_FromSpecWithBases: spec->name is dereferenced before checking for 
NULL
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com