From b7899d5f6fcd6b0f95e72445022f74aa11d083bc Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 25 Oct 2007 19:49:14 +0000 Subject: [PATCH] Added check against maxdata for write instructions. --- comedi/comedi_fops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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) -- 2.26.2