githubutilities / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

Unhandled error in builtin os.listdir #161

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Just compile and run:
    import os
    print os.listdir('/does/not/exist')

It should crash (Segmentation Fault). Instead, an OSError should be raised.

This happens with the last released version (0.9) and with the last git version 
(tested on GNU/Linux only).

The problem seems to be that in the C++ builtin os.listdir, the result of the 
call to opendir is not checked against 0 (0 is returned if the directory cannot 
be read). When 0 is returned, it is given to readdir which segfaults.

I attach a simple patch that fix this bug: check the result of opendir and 
raise an OSError if needed.

Original issue reported on code.google.com by pmdom...@gmail.com on 8 Dec 2011 at 10:42

Attachments:

GoogleCodeExporter commented 9 years ago
thanks a lot for the patch! :-) I pushed it, and added a small test to 
tests/198.py (which contains all tests so far for 0.9.1). 

Original comment by mark.duf...@gmail.com on 8 Dec 2011 at 7:39