classification
Title: fcntl.ioctl fails to copy back exactly-1024 buffer
Type: Stage: committed/rejected
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, eichin, nnorwitz (3)
Priority: normal Keywords:

Created on 2006-07-11 21:38 by eichin, last changed 2009-03-30 05:19 by ajaksu2.

Files
File name Uploaded Description Edit Remove
scsiinfo.py eichin, 2006-07-11 21:39 ioctl bug example
Messages (3)
msg29134 - (view) Author: Mark Eichin (eichin) Date: 2006-07-11 21:38
The appended code is a simple call of the SCSI Inquiry
ioctl, based on what scsi-tools scsiinfo.c does.  The
intended behaviour is simple - pass it /dev/sg0 (or any
scsi device, really) and it pulls out the vendor,
product and revision from the returned buffer.

However, if you change PAD_SIZE, the behaviour changes:
at 1023 and 1025, it does what is expected; at 1024,
the second assertion fires, because the array b on
output hasn't changed at all.

Not sure if there's a different ioctl that can
demonstrate this more easily (this needs root and a
scsi device, though it does explicitly open it
readonly) but it points in the direction of a fencepost
error in the "if the supplied buffer is less than 1024
bytes long it is first copied into a static buffer 1024
bytes long which is then passed to ioctl and copied
back into the supplied buffer" behaviour in current
documentation.

observed under:
Python 2.4.1 (#2, May  5 2005, 11:32:06)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
(on debian sarge.)

I didn't see it mentioned among the ioctl bugs in the
sourceforge tracker...
msg29135 - (view) Author: Neal Norwitz (nnorwitz) Date: 2006-07-12 05:33
Logged In: YES 
user_id=33168

This code was recently changed.  It is not in any released
version AFAIK.  Can you try 2.5b2 which recently came out? 
If not, can you try 2.4.3+ from SVN?  This is the version
that will become 2.4.4.  I think the problem may be fixed. 
The patch was for http://python.org/sf/1433877 .
msg84511 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-03-30 05:19
Closing due to lack of feedback.
History
Date User Action Args
2009-03-30 05:19:05ajaksu2setstatus: open -> closed

nosy: + ajaksu2
messages: + msg84511

resolution: out of date
stage: committed/rejected
2006-07-11 21:38:59eichincreate