Skip to content

Commit

Permalink
osd-target: mem_clear in case of OSD_ASC_READ_PAST_END_OF_USER_OBJECT
Browse files Browse the repository at this point in the history
If OSD_SSK_RECOVERED_ERROR/OSD_ASC_READ_PAST_END_OF_USER_OBJECT is
returned by target then extra bytes must be returned as zeros.
Other wise a bigger then OSD_SSK_RECOVERED_ERROR should be returned
like "offset or length, bad_parameter_in_cdb".

The problem was found by the holey cthon test.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
  • Loading branch information
Boaz Harrosh committed Mar 15, 2010
1 parent 1ca65bf commit 34f6296
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions osd-target/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2888,22 +2888,19 @@ static int contig_read(struct osd_device *osd, uint64_t pid, uint64_t oid,
goto out_cdb_err;

readlen = pread(fd, outdata, len, offset);
if (readlen < 0) {
close(fd);
goto out_hw_err;
}

ret = close(fd);
if (ret != 0)
if ((readlen < 0) || (ret != 0))
goto out_hw_err;

*used_outlen = readlen;

/* valid, but return a sense code */
if ((size_t) readlen < len)
if ((size_t) readlen < len) {
memset(outdata + readlen, 0, len - readlen);
ret = sense_build_sdd_csi(sense, OSD_SSK_RECOVERED_ERROR,
OSD_ASC_READ_PAST_END_OF_USER_OBJECT,
pid, oid, readlen);
}

*used_outlen = len;

fill_ccap(&osd->ccap, NULL, USEROBJECT, pid, oid, 0);
return ret;
Expand Down

0 comments on commit 34f6296

Please sign in to comment.