From fb31dd784b7dc1d21c61af167caca8da52f39d87 Mon Sep 17 00:00:00 2001
From: Andrew Johnson
Date: Tue, 31 Jul 2018 16:30:11 -0500
Subject: [PATCH] recGbl: Prevent record alarm severities > INVALID_ALARM
---
documentation/RELEASE_NOTES.html | 9 +++++++++
src/db/recGbl.c | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html
index b327e2430..fb5238bd1 100644
--- a/documentation/RELEASE_NOTES.html
+++ b/documentation/RELEASE_NOTES.html
@@ -16,6 +16,15 @@ Base-3.15 series or to EPICS 7.
+Prevent illegal alarm severities
+
+A check has been added to recGblResetAlarms() that prevents records
+from getting an alarm severity higher than INVALID_ALARM. It is still possible
+for a field like HSV to get set to a value that is not a legal alarm severity,
+but the core IOC code should never copy such a value into a record's SEVR or
+ACKS fields. With this fix the record's alarm severity will be limited to
+INVALID_ALARM.
+
Fixes for Launchpad bugs
The following launchpad bugs have fixes included:
diff --git a/src/db/recGbl.c b/src/db/recGbl.c
index 6d45e7333..01b2fa544 100644
--- a/src/db/recGbl.c
+++ b/src/db/recGbl.c
@@ -19,6 +19,7 @@
#include
#include "dbDefs.h"
+#include "alarm.h"
#include "epicsMath.h"
#include "epicsTime.h"
#include "epicsPrint.h"
@@ -222,6 +223,9 @@ unsigned short epicsShareAPI recGblResetAlarms(void *precord)
epicsEnum16 val_mask = 0;
epicsEnum16 stat_mask = 0;
+ if (new_sevr > INVALID_ALARM)
+ new_sevr = INVALID_ALARM;
+
pdbc->stat = new_stat;
pdbc->sevr = new_sevr;
pdbc->nsta = 0;