From: Frank Mori Hess Date: Thu, 25 Oct 2007 19:49:14 +0000 (+0000) Subject: Added check against maxdata for write instructions. X-Git-Tag: r0_7_75~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b7899d5f6fcd6b0f95e72445022f74aa11d083bc;p=comedi.git Added check against maxdata for write instructions. --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index d1a69a86..29134bdc 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -663,6 +663,7 @@ static int parse_insn(comedi_device *dev,comedi_insn *insn,lsampl_t *data,void * { comedi_subdevice *s; int ret = 0; + int i; if(insn->insn&INSN_MASK_SPECIAL){ /* a non-subdevice instruction */ @@ -760,8 +761,12 @@ static int parse_insn(comedi_device *dev,comedi_insn *insn,lsampl_t *data,void * ret=s->insn_read(dev,s,insn,data); break; case INSN_WRITE: - //XXX check against subdevice's maxdata - ret=s->insn_write(dev,s,insn,data); + for(i = 0; i < insn->n; ++i) + { + if(data[i] > s->maxdata) ret = -EINVAL; + } + if(ret == 0) + ret = s->insn_write(dev,s,insn,data); break; case INSN_BITS: if(insn->n != 2)