Date: Sun, 24 May 2009 17:44:07 GMT From: Alexander Motin <mav@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 162660 for review Message-ID: <200905241744.n4OHi7Q6079312@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=162660 Change 162660 by mav@mav_mavbook on 2009/05/24 17:43:58 Serial number may be not terminated. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#4 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#4 (text+ko) ==== @@ -485,7 +485,6 @@ struct ata_params *ident_buf; int16_t *ptr; - path->device->flags |= CAM_DEV_INQUIRY_DATA_VALID; ident_buf = &path->device->ident_data; for (ptr = (int16_t *)ident_buf; @@ -507,8 +506,26 @@ btrim(ident_buf->serial, sizeof(ident_buf->serial)); bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial)); - path->device->serial_num = ident_buf->serial; - path->device->serial_num_len = strlen(ident_buf->serial); + /* Clean up from previous instance of this device */ + if (path->device->serial_num != NULL) { + free(path->device->serial_num, M_CAMXPT); + path->device->serial_num = NULL; + path->device->serial_num_len = 0; + } + path->device->serial_num = + (u_int8_t *)malloc((sizeof(ident_buf->serial) + 1), + M_CAMXPT, M_NOWAIT); + if (path->device->serial_num != NULL) { + bcopy(ident_buf->serial, + path->device->serial_num, + sizeof(ident_buf->serial)); + path->device->serial_num[sizeof(ident_buf->serial)] + = '\0'; + path->device->serial_num_len = + strlen(path->device->serial_num); + } + + path->device->flags |= CAM_DEV_INQUIRY_DATA_VALID; scsi_find_quirk(path->device);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905241744.n4OHi7Q6079312>