From 0f2025bd71860833146ca56edb9cf03106eafb5f Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Thu, 9 May 2013 16:40:16 +0200 Subject: [PATCH] Initialize client rate and channel ranges. Fixes crashes when the client doesn't set the rate and/or channel ranges. Problem reported and analyzed by Dimitri Sokolyuk . Thanks! --- sndiod/dev.c | 13 +++++++------ sndiod/sock.c | 17 ++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sndiod/dev.c b/sndiod/dev.c index ab4c929..65dc429 100644 --- a/sndiod/dev.c +++ b/sndiod/dev.c @@ -1560,21 +1560,22 @@ found: return 0; } s->mode = mode; - s->par = d->par; + aparams_init(&s->par); if (s->mode & MODE_PLAY) { - s->mix.slot_cmin = 0; - s->mix.slot_cmax = d->pchan - 1; + s->mix.slot_cmin = s->mix.dev_cmin = 0; + s->mix.slot_cmax = s->mix.dev_cmax = d->pchan - 1; } if (s->mode & MODE_RECMASK) { - s->sub.slot_cmin = 0; - s->sub.slot_cmax = ((s->mode & MODE_MON) ? - d->pchan : d->rchan) - 1; + s->sub.slot_cmin = s->sub.dev_cmin = 0; + s->sub.slot_cmax = s->sub.dev_cmax = + ((s->mode & MODE_MON) ? d->pchan : d->rchan) - 1; } s->xrun = XRUN_IGNORE; s->dup = 0; s->appbufsz = d->bufsz; s->round = d->round; s->rate = d->rate; + s->mix.maxweight = ADATA_UNIT; dev_midi_slotdesc(d, s); dev_midi_vol(d, s); return s; diff --git a/sndiod/sock.c b/sndiod/sock.c index ea364da..6d62aef 100644 --- a/sndiod/sock.c +++ b/sndiod/sock.c @@ -670,13 +670,13 @@ sock_setpar(struct sock *f) if (log_level >= 3) { sock_log(f); log_puts(": recording channels "); - log_putu(s->sub.slot_cmin); - log_puts(":"); - log_putu(s->sub.slot_cmax); - log_puts(" -> "); log_putu(s->sub.dev_cmin); log_puts(":"); log_putu(s->sub.dev_cmax); + log_puts(" -> "); + log_putu(s->sub.slot_cmin); + log_puts(":"); + log_putu(s->sub.slot_cmax); log_puts("\n"); } #endif @@ -907,14 +907,13 @@ sock_hello(struct sock *f) if (s == NULL) return 0; f->midi = NULL; - aparams_init(&s->par); if (s->mode & MODE_PLAY) { - s->mix.slot_cmin = f->opt->pmin; - s->mix.slot_cmax = f->opt->pmax; + s->mix.slot_cmin = s->mix.dev_cmin = f->opt->pmin; + s->mix.slot_cmax = s->mix.dev_cmax = f->opt->pmax; } if (s->mode & MODE_RECMASK) { - s->sub.slot_cmin = f->opt->rmin; - s->sub.slot_cmax = f->opt->rmax; + s->sub.slot_cmin = s->sub.dev_cmin = f->opt->rmin; + s->sub.slot_cmax = s->sub.dev_cmax = f->opt->rmax; } if (f->opt->mmc) { s->xrun = XRUN_SYNC;