Mercurial > illumos > illumos-gate
changeset 9905:6ec9863bc3c6
6588049 get_current_profile() sends a bad GET CONFIGURATION command resulting in ATA target resets.
author | Xiaolin Zhang - Sun Microsystems - Beijing China <Xiao-Lin.Zhang@Sun.COM> |
---|---|
date | Fri, 19 Jun 2009 14:52:09 +0800 |
parents | d260bd3fd47c |
children | bfc3790e8ac6 |
files | usr/src/cmd/hal/utils/cdutils.c |
diffstat | 1 files changed, 19 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/hal/utils/cdutils.c Thu Jun 18 21:41:20 2009 -0600 +++ b/usr/src/cmd/hal/utils/cdutils.c Fri Jun 19 14:52:09 2009 +0800 @@ -2,14 +2,13 @@ * * cdutils.c : CD/DVD utilities * - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Licensed under the Academic Free License version 2.1 * **************************************************************************/ -#pragma ident "%Z%%M% %I% %E% SMI" #ifdef HAVE_CONFIG_H # include <config.h> @@ -212,13 +211,19 @@ get_current_profile(int fd, int *profile) { size_t i; - uchar_t smallbuf[4]; + uchar_t smallbuf[8]; size_t buflen; uchar_t *bufp; int ret = B_FALSE; - /* first determine amount of memory needed to hold all profiles */ - if (get_configuration(fd, 0, 4, &smallbuf[0])) { + /* + * first determine amount of memory needed to hold all profiles. + * The first four bytes of smallbuf concatenated tell us the + * number of bytes of memory we need but do not take themselves + * into account. Therefore, add four to allocate that number + * of bytes. + */ + if (get_configuration(fd, 0, 8, &smallbuf[0])) { buflen = GET32(smallbuf) + 4; bufp = (uchar_t *)malloc(buflen); @@ -238,13 +243,19 @@ { size_t i; uint16_t profile, current_profile; - uchar_t smallbuf[4]; + uchar_t smallbuf[8]; size_t buflen; uchar_t *bufp; int ret; - /* first determine amount of memory needed to hold all profiles */ - if (get_configuration(fd, 0, 4, &smallbuf[0])) { + /* + * first determine amount of memory needed to hold all profiles. + * The first four bytes of smallbuf concatenated tell us the + * number of bytes of memory we need but do not take themselves + * into account. Therefore, add four to allocate that number + * of bytes. + */ + if (get_configuration(fd, 0, 8, &smallbuf[0])) { buflen = GET32(smallbuf) + 4; bufp = (uchar_t *)malloc(buflen);