From: Frank Mori Hess Date: Sun, 6 Mar 2005 17:30:40 +0000 (+0000) Subject: move some checks for length of data[] in configuration insn to core X-Git-Tag: r0_7_70~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8eb9f4f73cf098eb9fdc23723af805e2ab90addb;p=comedi.git move some checks for length of data[] in configuration insn to core --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index a49361a3..5fd9de13 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -619,6 +619,27 @@ error: return i; } +static int check_insn_config_length(comedi_insn *insn, lsampl_t *data) +{ + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: + case INSN_CONFIG_DIO_INPUT: + if(insn->n == 1) return 0; + break; + case INSN_CONFIG_DIO_QUERY: + if(insn->n == 2) return 0; + break; + case INSN_CONFIG_BLOCK_SIZE: + if( insn->n == 2 ) return 0; + //by default we allow the insn since we don't have checks for all possible cases yet + default: + return 0; + break; + } + return -EINVAL; +} + static int parse_insn(comedi_device *dev,comedi_insn *insn,lsampl_t *data,void *file) { comedi_subdevice *s; @@ -727,6 +748,8 @@ static int parse_insn(comedi_device *dev,comedi_insn *insn,lsampl_t *data,void * ret=s->insn_bits(dev,s,insn,data); break; case INSN_CONFIG: + ret=check_insn_config_length(insn); + if(ret) break; ret=s->insn_config(dev,s,insn,data); break; default: