aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/arcmsr
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2017-01-04 20:26:42 +0000
committerAlan Somers <asomers@FreeBSD.org>2017-01-04 20:26:42 +0000
commit4195c7de2471d6212744bcbf128d659e94801d17 (patch)
tree7fdef0b78cad4790c16b1209161939aeb9cb7b44 /sys/dev/arcmsr
parente39ff5dd0bdfc2e7dc8cd6883ddd66d88f24b668 (diff)
downloadsrc-4195c7de2471d6212744bcbf128d659e94801d17.tar.gz
src-4195c7de2471d6212744bcbf128d659e94801d17.zip
Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)
The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are fixed-length strings. AFAICT the only place they're read is in sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated. However, the kernel doesn't null-terminate them. A bunch of copy-pasted code uses strncpy to write them, and doesn't guarantee null-termination. For at least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually overflows. You can see the result by doing "camcontrol negotiate da0 -v". This change null-terminates those fields everywhere they're set in the kernel. It also shortens a few strings to ensure they'll fit within the 16-character field. PR: 215474 Reported by: Coverity CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005 CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000 CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014 CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021 CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027 CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187 CID: 1010035 1010036 1010042 1010041 1010040 1010039 Reviewed by: imp, sephe, slm MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D9037 Differential Revision: https://reviews.freebsd.org/D9038
Notes
Notes: svn path=/head/; revision=311305
Diffstat (limited to 'sys/dev/arcmsr')
-rw-r--r--sys/dev/arcmsr/arcmsr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c
index cabb99a7ad61..f293db0a7be3 100644
--- a/sys/dev/arcmsr/arcmsr.c
+++ b/sys/dev/arcmsr/arcmsr.c
@@ -2901,9 +2901,9 @@ static void arcmsr_action(struct cam_sim *psim, union ccb *pccb)
cpi->max_lun = ARCMSR_MAX_TARGETLUN; /* 0-7 */
cpi->initiator_id = ARCMSR_SCSI_INITIATOR_ID; /* 255 */
cpi->bus_id = cam_sim_bus(psim);
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN);
- strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN);
+ strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+ strlcpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN);
+ strlcpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN);
cpi->unit_number = cam_sim_unit(psim);
#ifdef CAM_NEW_TRAN_CODE
if(acb->adapter_bus_speed == ACB_BUS_SPEED_12G)