diff --git a/lib/libossaudio/ossaudio.c b/lib/libossaudio/ossaudio.c index 3a7773bfc338..34c413009069 100644 --- a/lib/libossaudio/ossaudio.c +++ b/lib/libossaudio/ossaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.30 2014/09/09 10:45:18 nat Exp $ */ +/* $NetBSD: ossaudio.c,v 1.31 2017/02/10 08:50:27 maya Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: ossaudio.c,v 1.30 2014/09/09 10:45:18 nat Exp $"); +__RCSID("$NetBSD: ossaudio.c,v 1.31 2017/02/10 08:50:27 maya Exp $"); /* * This is an OSS (Linux) sound API emulator. @@ -497,12 +497,9 @@ audio_ioctl(int fd, unsigned long com, void *argp) *(struct count_info *)argp = cntinfo; break; case SNDCTL_SYSINFO: - strncpy(tmpsysinfo.product, "OSS/NetBSD", 31); - tmpsysinfo.product[31] = 0; - strncpy(tmpsysinfo.version, version, 31); - tmpsysinfo.version[31] = 0; - strncpy(tmpsysinfo.license, license, 15); - tmpsysinfo.license[15] = 0; + strlcpy(tmpsysinfo.product, "OSS/NetBSD", sizeof tmpsysinfo.product); + strlcpy(tmpsysinfo.version, version, sizeof tmpsysinfo.version); + strlcpy(tmpsysinfo.license, license, sizeof tmpsysinfo.license); tmpsysinfo.versionnum = SOUND_VERSION; memset(tmpsysinfo.options, 0, 8); tmpsysinfo.numaudios = OSS_MAX_AUDIO_DEVS; @@ -550,8 +547,8 @@ audio_ioctl(int fd, unsigned long com, void *argp) if (idata & AUDIO_PROP_MMAP) idat |= DSP_CAP_MMAP; idat = PCM_CAP_INPUT | PCM_CAP_OUTPUT; - strncpy(tmpaudioinfo->name, tmpaudiodev.name, 64); - tmpaudioinfo->name[63] = 0; + strlcpy(tmpaudioinfo->name, tmpaudiodev.name, + sizeof tmpaudioinfo->name); tmpaudioinfo->busy = tmpinfo.play.open; tmpaudioinfo->pid = -1; tmpaudioinfo->caps = idat; @@ -799,7 +796,7 @@ getdevinfo(int fd) di->devmask |= 1 << dp->code; if (mi.un.v.num_channels == 2) di->stereomask |= 1 << dp->code; - strncpy(di->names[i], mi.label.name, + strlcpy(di->names[i], mi.label.name, sizeof di->names[i]); } break; @@ -866,8 +863,8 @@ mixer_ioctl(int fd, unsigned long com, void *argp) omi = argp; if (com == SOUND_MIXER_INFO) omi->modify_counter = 1; - strncpy(omi->id, adev.name, sizeof omi->id); - strncpy(omi->name, adev.name, sizeof omi->name); + strlcpy(omi->id, adev.name, sizeof omi->id); + strlcpy(omi->name, adev.name, sizeof omi->name); return 0; case SOUND_MIXER_READ_RECSRC: if (di->source == -1)