aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-01-14 02:08:27 +0000
committerEric Wong <normalperson@yhbt.net>2007-01-14 02:08:27 +0000
commitf894e989509f8e484276ad6ec1fbbac238d78dd1 (patch)
treeb167d6d0008b7dfab1ddebcb591e3d299774a461 /src/audioOutputs
parente1ee4505debf118f8f16c322decf1457061ae979 (diff)
downloadmpd-f894e989509f8e484276ad6ec1fbbac238d78dd1.tar.gz
mpd-f894e989509f8e484276ad6ec1fbbac238d78dd1.tar.xz
mpd-f894e989509f8e484276ad6ec1fbbac238d78dd1.zip
jack: fix potential segfaults in parsing bad configs for 'ports'
git-svn-id: https://svn.musicpd.org/mpd/trunk@5251 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs')
-rw-r--r--src/audioOutputs/audioOutput_jack.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/audioOutputs/audioOutput_jack.c b/src/audioOutputs/audioOutput_jack.c
index 186f3396f..c5eeab728 100644
--- a/src/audioOutputs/audioOutput_jack.c
+++ b/src/audioOutputs/audioOutput_jack.c
@@ -175,11 +175,27 @@ static int jack_initDriver(AudioOutput *audioOutput, ConfigParam *param)
if ( ! param ) return 0;
if ( (bp = getBlockParam(param, "ports")) ) {
- cp = xstrdup(bp->value);
- ERROR("output_ports=%s\n", cp);
- output_ports[0] = xstrdup(strtok (cp, ","));
- output_ports[1] = xstrdup(strtok (NULL, ","));
- free(cp);
+ DEBUG("output_ports=%s\n", bp->value);
+
+ if (!(cp = strchr(bp->value, ',')))
+ FATAL("expected comma and a second value for '%s' "
+ "at line %d: %s\n",
+ bp->name, bp->line, bp->value);
+
+ *cp = '\0';
+ output_ports[0] = xstrdup(bp->value);
+ *cp++ = ',';
+
+ if (!*cp)
+ FATAL("expected a second value for '%s' at line %d: "
+ "%s\n", bp->name, bp->line, bp->value);
+
+ output_ports[1] = xstrdup(cp);
+
+ if (strchr(cp,','))
+ FATAL("Only %d values are supported for '%s' "
+ "at line %d\n",
+ ARRAY_SIZE(output_ports), bp->name, bp->line);
}
if ( (bp = getBlockParam(param, "ringbuffer_size")) ) {