Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue15676] mmap: add empty file check prior to offset check

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Aug 15, 2012, 10:46 AM

Post #1 of 3 (315 views)
Permalink
[issue15676] mmap: add empty file check prior to offset check

New submission from Steven Willis:

There are a number of issues dealing with the offset and length checks in offset, such as issue12556.

I'm running into this issue as well, but with a normal file that happens to be empty. I'm trying to access it with:

mmap.mmap(f.fileno(), length=0, access=mmap.ACCESS_READ)

So the length and offset should be calculated automatically. The man page for mmap says:

"SUSv3 specifies that mmap() should fail if length is 0. However, in kernels before 2.6.12, mmap() succeeded in this case: no mapping was created and the call returned addr. Since kernel 2.6.12, mmap() fails with the error EINVAL for this case."

So alright, mmapping an empty file is now allowed. But, could the check for an empty file be done prior to the check for the offset exceeding the size of the file? It would be much clearer in the cases where an empty (regular or otherwise) file was mmapped if the error message were something like "empty files cannot be mapped" insted of "offset is greater than file size" since I didn't even set the offset.

----------
components: Library (Lib)
messages: 168314
nosy: Steven.Willis
priority: normal
severity: normal
status: open
title: mmap: add empty file check prior to offset check
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15676>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 15, 2012, 1:06 PM

Post #2 of 3 (297 views)
Permalink
[issue15676] mmap: add empty file check prior to offset check [In reply to]

Changes by Jesús Cea Avión <jcea [at] jcea>:


----------
nosy: +jcea

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15676>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 15, 2012, 1:08 PM

Post #3 of 3 (297 views)
Permalink
[issue15676] mmap: add empty file check prior to offset check [In reply to]

Jesús Cea Avión added the comment:

I do agree. Solaris also returns an error if len=0.

Could you please, provide patches for 2.7, 3.2 and 3.3?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15676>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.