From 6039647e134b2bcb0f36dcf4041dcd430893e58c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 20 Jul 2007 19:23:50 +0000 Subject: [PATCH] Handle SELN >= SEL_MAX without crashing (Mantis #295) --- src/rec/selRecord.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/rec/selRecord.c b/src/rec/selRecord.c index 361d9ebc0..95adbf7d6 100644 --- a/src/rec/selRecord.c +++ b/src/rec/selRecord.c @@ -1,19 +1,16 @@ /*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* Copyright (c) 2007 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found +* EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ -/* recSel.c */ -/* base/src/rec $Id$ */ +/* $Id$ */ -/* recSel.c - Record Support Routines for Select records */ +/* selRecord.c - Record Support Routines for Select records */ /* * Original Author: Bob Dalesio - * Current Author: Marty Kraimer * Date: 6-2-89 */ @@ -346,6 +343,10 @@ static int do_sel(struct selRecord *psel) pvalue = &psel->a; switch (psel->selm){ case (selSELM_Specified): + if (psel->seln >= SEL_MAX) { + recGblSetSevr(psel,SOFT_ALARM,MAJOR_ALARM); + return(0); + } val = *(pvalue+psel->seln); break; case (selSELM_High_Signal): @@ -417,6 +418,11 @@ static int fetch_values(struct selRecord *psel) status=dbGetLink(&(psel->nvl),DBR_USHORT,&(psel->seln),0,0); if (!RTN_SUCCESS(status)) return(status); + if (psel->seln >= SEL_MAX) { + recGblSetSevr(psel,SOFT_ALARM,MAJOR_ALARM); + return(-1); + } + plink += psel->seln; pvalue += psel->seln;