Source-Changes-HG archive

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

[src/trunk]: src/lib/libossaudio strncpy->strlcpy. use sizeof instead of numb...



details:   https://anonhg.NetBSD.org/src/rev/e563e2139ea2
branches:  trunk
changeset: 821591:e563e2139ea2
user:      maya <maya%NetBSD.org@localhost>
date:      Fri Feb 10 08:50:27 2017 +0000

description:
strncpy->strlcpy. use sizeof instead of numbers.

diffstat:

 lib/libossaudio/ossaudio.c |  23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diffs (65 lines):

diff -r 5d9f4cd3b386 -r e563e2139ea2 lib/libossaudio/ossaudio.c
--- a/lib/libossaudio/ossaudio.c        Fri Feb 10 08:48:06 2017 +0000
+++ b/lib/libossaudio/ossaudio.c        Fri Feb 10 08:50:27 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
                *(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 @@
                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 @@
                                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 @@
                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)



Home | Main Index | Thread Index | Old Index