From 4e9fecc767104a1f3cbc462d877028be2fa22dc3 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 26 Jan 2025 23:17:30 +0800 Subject: [PATCH] Sound (NetBSD): don't assume readlink reports file name only --- src/detection/sound/sound_bsd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/detection/sound/sound_bsd.c b/src/detection/sound/sound_bsd.c index b3b813b27..fd6236cf1 100644 --- a/src/detection/sound/sound_bsd.c +++ b/src/detection/sound/sound_bsd.c @@ -15,10 +15,11 @@ const char* ffDetectSound(FFlist* devices) #else int defaultDev; { - char mixerp[8]; - if (readlink("/dev/mixer", mixerp, ARRAY_SIZE(mixerp)) != 6) + char mixerp[12]; + ssize_t plen = readlink("/dev/mixer", mixerp, ARRAY_SIZE(mixerp)); + if (plen < 6) return "readlink(/dev/mixer) failed"; - defaultDev = mixerp[5] - '0'; + defaultDev = mixerp[plen - 1] - '0'; if (defaultDev < 0 || defaultDev > 9) return "Invalid mixer device"; }