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
This commit is contained in:
parent
e1ee4505de
commit
f894e98950
@ -175,11 +175,27 @@ static int jack_initDriver(AudioOutput *audioOutput, ConfigParam *param)
|
|||||||
if ( ! param ) return 0;
|
if ( ! param ) return 0;
|
||||||
|
|
||||||
if ( (bp = getBlockParam(param, "ports")) ) {
|
if ( (bp = getBlockParam(param, "ports")) ) {
|
||||||
cp = xstrdup(bp->value);
|
DEBUG("output_ports=%s\n", bp->value);
|
||||||
ERROR("output_ports=%s\n", cp);
|
|
||||||
output_ports[0] = xstrdup(strtok (cp, ","));
|
if (!(cp = strchr(bp->value, ',')))
|
||||||
output_ports[1] = xstrdup(strtok (NULL, ","));
|
FATAL("expected comma and a second value for '%s' "
|
||||||
free(cp);
|
"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")) ) {
|
if ( (bp = getBlockParam(param, "ringbuffer_size")) ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user