Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/hdaudio Fix off-by-one when calling snprintf(9) in h...



details:   https://anonhg.NetBSD.org/src/rev/f66a02290dfe
branches:  trunk
changeset: 828802:f66a02290dfe
user:      khorben <khorben%NetBSD.org@localhost>
date:      Thu Jan 04 00:09:12 2018 +0000

description:
Fix off-by-one when calling snprintf(9) in hdafg_getdev()

This is actually harmless, since:
- the offset is too short rather than too long (no overflow)
- the struct audio_device comes from userland (no information leak)

"looks good to me" nat@

diffstat:

 sys/dev/hdaudio/hdafg.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 66436e2fe9e3 -r f66a02290dfe sys/dev/hdaudio/hdafg.c
--- a/sys/dev/hdaudio/hdafg.c   Wed Jan 03 09:46:41 2018 +0000
+++ b/sys/dev/hdaudio/hdafg.c   Thu Jan 04 00:09:12 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.13 2017/08/04 00:25:23 mrg Exp $ */
+/* $NetBSD: hdafg.c,v 1.14 2018/01/04 00:09:12 khorben Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.13 2017/08/04 00:25:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.14 2018/01/04 00:09:12 khorben Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -4058,7 +4058,7 @@
            sc->sc_vendor);
        hdaudio_findproduct(audiodev->version, sizeof(audiodev->version),
            sc->sc_vendor, sc->sc_product);
-       snprintf(audiodev->config, sizeof(audiodev->config) - 1,
+       snprintf(audiodev->config, sizeof(audiodev->config),
            "%02Xh", sc->sc_nid);
 
        return 0;



Home | Main Index | Thread Index | Old Index