NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/47676: Off-by-one error in reported CD capacity means last sector cannot be read



On Thu, March 21, 2013 17:30, Michael van Elst wrote:
> The following reply was made to PR kern/47676; it has been noted by GNATS.
>
> From: mlelstv%serpens.de@localhost (Michael van Elst)
> To: gnats-bugs%netbsd.org@localhost
> Cc:
> Subject: Re: kern/47676: Off-by-one error in reported CD capacity means
> last sector cannot be read
> Date: Thu, 21 Mar 2013 17:28:31 +0000 (UTC)
>
>  Seems to be slightly more complex.
>
>  read_cd_capacity(struct scsipi_periph *periph, u_int *blksize, u_long
> *size)
>  error = read_cd_capacity(cd->sc_periph, &blksize, &size);
>  error = read_cd_capacity(cd->sc_periph, &blksize, &size);
>  error = read_cd_capacity(periph, &mmc_discinfo->sector_size, &last_lba);
>
>  One time the caller apparently expects the last_lba value as is returned
>  by the READ RECORDED CD CAPACITY command.

I don't think the caller does, though the last_lba variable name is quite
misleading.

The caller is the mmc_getdiscinfo() function in src/sys/dev/scsipi/cd.c.
Code around line 3005 in the NetBSD 6.0.1 source:
        error = read_cd_capacity(periph, &mmc_discinfo->sector_size, &last_lba);
        if (error)
                goto out;

        mmc_discinfo->last_possible_lba = (uint32_t) last_lba - 1;

So last_possible_lba is set assuming that the "last_lba" variable is
actually the total number of sectors, i.e. the number of the last LBA + 1.
No code change is needed there, though someone might want to rename
last_lba to be less confusing.





Home | Main Index | Thread Index | Old Index