From 8759261bd5e47218185ae92458c22e92af4ff16b Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 19 Oct 2006 20:56:40 +0000 Subject: [PATCH] Added some more data length checks for config instructions to comedi_fops.c --- comedi/comedi_fops.c | 17 +++++++++++++---- comedi/drivers/amplc_dio200.c | 4 +--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 07831732..a14856a5 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -635,17 +635,26 @@ static int check_insn_config_length(comedi_insn *insn, lsampl_t *data) case INSN_CONFIG_BLOCK_SIZE: case INSN_CONFIG_SERIAL_CLOCK: case INSN_CONFIG_BIDIRECTIONAL_DATA: - case INSN_CONFIG_SET_RTSI_CLOCK_MODE: case INSN_CONFIG_ALT_SOURCE: - if( insn->n == 2 ) return 0; + case INSN_CONFIG_8254_SET_MODE: + case INSN_CONFIG_8254_READ_STATUS: + case INSN_CONFIG_SET_GATE_SRC: + case INSN_CONFIG_GET_GATE_SRC: + if(insn->n == 2) return 0; + break; + case INSN_CONFIG_SET_CLOCK_SRC: + case INSN_CONFIG_GET_CLOCK_SRC: + if(insn->n == 3) return 0; break; case INSN_CONFIG_PWM_OUTPUT: if(insn->n == 5) return 0; break; //by default we allow the insn since we don't have checks for all possible cases yet default: - rt_printk("comedi: no check for data length of config insn id %i implemented. Assuming n=%i is correct.\n", - data[0], insn->n); + rt_printk("comedi: no check for data length of config insn id %i is implemented.\n" + " Add a check to %s in %s.\n" + " Assuming n=%i is correct.\n", + data[0], __FUNCTION__, __FILE__, insn->n); return 0; break; } diff --git a/comedi/drivers/amplc_dio200.c b/comedi/drivers/amplc_dio200.c index c4d33ba8..85022b12 100644 --- a/comedi/drivers/amplc_dio200.c +++ b/comedi/drivers/amplc_dio200.c @@ -1072,8 +1072,6 @@ dio200_subdev_8254_config(comedi_device *dev, comedi_subdevice *s, int ret; int chan = CR_CHAN(insn->chanspec); - if (insn->n != 2) return -EINVAL; - switch (data[0]) { case INSN_CONFIG_8254_SET_MODE: ret = i8254_set_mode(subpriv->iobase, chan, data[1]); @@ -1104,7 +1102,7 @@ dio200_subdev_8254_config(comedi_device *dev, comedi_subdevice *s, return -EINVAL; break; } - return 2; + return insn->n; } /* -- 2.26.2