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.

Author neologix
Recipients neologix, pitrou, vstinner
Date 2011-06-09.18:13:22
SpamBayes Score 2.4424907e-15
Marked as misclassified No
Message-id <BANLkTinr_0hANceEV8mUJCVLp6kU7GnqBA@mail.gmail.com>
In-reply-to <1307569986.96.0.534178412085.issue12287@psf.upfronthosting.co.za>
Content
> You don't check that 0 <= fd (e.g. oss.close()).
>

Actually, none of ossaudiodev's method does...

This makes it even easier to trigger a segfault (at least on RHEL4):
"""
import ossaudiodev

o = ossaudiodev.open('/dev/dsp', 'w')
o.close()
o.writeall(b'toto')
"""

I've attached a patch to fix that (check that the underlying FD isn't closed).

> The select has a specific code for Visual Studio (don't check v < FD_SETSIZE):

> Python has a _PyVerify_fd() function. We might write a similar function/macro to check if a file descriptor can be used in a file descriptor set. FD_SET() is used in the oss, readline, socket and _ssl modules. The socket module has a IS_SELECTABLE() macro:

So, this _PyCheckSelectable_fd ? function/macro would:
- return true (1) on Visual Studio or if
Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE is defined
- return false (0) if the file descriptor is greater than FD_SETSIZE otherwise
Do we agree on that?
Where should I add it? selectmodule, posixmodule, somewhere else?

>
> Note: do you really use the OSS module? On which OS? :)
>

Well, while we don't use ossaudiodev, we have a couple hundred Linux
machines at work, and we use OSS on Linux 2.6.9 kernels (and Python
2.3.4 ;-) )
Files
File name Uploaded
oss_check_closed.diff neologix, 2011-06-09.18:13:21
History
Date User Action Args
2011-06-09 18:13:24neologixsetrecipients: + neologix, pitrou, vstinner
2011-06-09 18:13:23neologixlinkissue12287 messages
2011-06-09 18:13:22neologixcreate