Re: SCSI disk devices

eyal (eyal@eyal.emu.id.au)
Sun, 04 May 1997 00:51:26 +1000


Hello Everyone,

While we mention the scsidev program, I grabbed scsidev-1.5 (the
latest?)
and had it segfault. Here is what I had to fix:

There are a number of problems with get_serial_number() function. I only
saw these when using the '-s' option.

1) It has some early returns, before setting '->serial'.
The call for 'if (show_serial)' does not expect it, and does
not check for NULL after the call.
- set '->serial' to 'no_serial' right at the start of the function.

2) The ioctl says the output buffer size is 1024. This is wrong,
it is only 1024-8. I got segfaults because of this.
- use:
((int *)buffer)[0] = 0; /* length of input buffer */
((int *)buffer)[1] = 1024-8; /* length of output buffer */
cmd = ...

3) If the ioctl fails, '->serial' is set to 'no_serial' but we
still proceed to copy the serial number from the buffer.
- after the ioctl replace:
if (status) ...
... a block ...
/* Copy information to identical...
with:
if (!status) {
... a block ...
}
/* Copy information to identical...

4) And while we are here, I would trim the serial number (in the above
block) before the malloc (still in 'buffer') rather than after. Not
a real problem.

Actually, I think this program *is* alpha status, it looks like it was
never properly cleaned up for release (often does not check returned
values
etc.) but it *does* work and is very nice. If Eric is busy, better
release
alpha than not at all...

--
Eyal Lebedinsky		(eyal@eyal.emu.id.au)