db: validate dbrType

This commit is contained in:
Michael Davidsaver
2020-06-01 08:25:55 -07:00
parent d6f8e9038c
commit 6c914d19c3
7 changed files with 44 additions and 5 deletions
+12 -2
View File
@@ -553,7 +553,12 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer,
dbCommon *prec = plink->precord;
int i;
long status;
FASTCONVERT conv = dbFastPutConvertRoutine[DBR_DOUBLE][dbrType];
FASTCONVERT conv;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
conv = dbFastPutConvertRoutine[DBR_DOUBLE][dbrType];
/* Any link errors will trigger a LINK/INVALID alarm in the child link */
for (i = 0; i < clink->nArgs; i++) {
@@ -624,7 +629,12 @@ static long lnkCalc_putValue(struct link *plink, short dbrType,
dbCommon *prec = plink->precord;
int i;
long status;
FASTCONVERT conv = dbFastGetConvertRoutine[dbrType][DBR_DOUBLE];
FASTCONVERT conv;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
conv = dbFastGetConvertRoutine[dbrType][DBR_DOUBLE];
/* Any link errors will trigger a LINK/INVALID alarm in the child link */
for (i = 0; i < clink->nArgs; i++) {
+9 -1
View File
@@ -361,6 +361,9 @@ static long lnkConst_loadScalar(struct link *plink, short dbrType, void *pbuffer
const_link *clink = CONTAINER(plink->value.json.jlink, const_link, jlink);
long status;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
switch (clink->type) {
case si64:
if (clink->jlink.debug)
@@ -451,12 +454,17 @@ static long lnkConst_loadArray(struct link *plink, short dbrType, void *pbuffer,
long *pnReq)
{
const_link *clink = CONTAINER(plink->value.json.jlink, const_link, jlink);
short dbrSize = dbValueSize(dbrType);
short dbrSize;
char *pdest = pbuffer;
int nElems = clink->nElems;
FASTCONVERT conv;
long status;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
dbrSize = dbValueSize(dbrType);
if (nElems > *pnReq)
nElems = *pnReq;
+6 -1
View File
@@ -142,7 +142,12 @@ static long lnkState_getValue(struct link *plink, short dbrType, void *pbuffer,
{
state_link *slink = CONTAINER(plink->value.json.jlink,
struct state_link, jlink);
FASTCONVERT conv = dbFastPutConvertRoutine[DBR_SHORT][dbrType];
FASTCONVERT conv;
if(INVALID_DB_REQ(dbrType))
return S_db_badDbrtype;
conv = dbFastPutConvertRoutine[DBR_SHORT][dbrType];
slink->val = slink->invert ^ dbStateGet(slink->state);
return conv(&slink->val, pbuffer, NULL);