Limit max ctl value to c->maxval, not 127.

This commit is contained in:
Alexandre Ratchov 2020-02-22 16:32:22 +01:00
parent c2226012ed
commit 1bbb66b0c0
1 changed files with 9 additions and 9 deletions

View File

@ -2340,15 +2340,6 @@ dev_setctl(struct dev *d, int addr, int val)
struct ctl *c;
int num;
if (val < 0 || val > MIDI_MAXCTL) {
if (log_level >= 3) {
dev_log(d);
log_puts(": ");
log_putu(val);
log_puts(": ctl val out of bounds\n");
}
return 0;
}
c = d->ctl_list;
for (;;) {
if (c == NULL) {
@ -2371,6 +2362,15 @@ dev_setctl(struct dev *d, int addr, int val)
}
return 1;
}
if (val < 0 || val > c->maxval) {
if (log_level >= 3) {
dev_log(d);
log_puts(": ");
log_putu(val);
log_puts(": ctl val out of bounds\n");
}
return 0;
}
if (addr >= CTLADDR_END) {
if (log_level >= 3) {
ctl_log(c);