From 9014ca899d97a25a4617763e908849f207da5fbb Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 30 Jul 2015 11:57:50 -0500 Subject: [PATCH] dbStatic: Fix invalid memory read --- src/dbStatic/dbStaticLib.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dbStatic/dbStaticLib.c b/src/dbStatic/dbStaticLib.c index a3648f3bf..1a5d716e7 100644 --- a/src/dbStatic/dbStaticLib.c +++ b/src/dbStatic/dbStaticLib.c @@ -1375,14 +1375,19 @@ long epicsShareAPI dbGetAttributePart(DBENTRY *pdbentry, const char **ppname) const char *pname = *ppname; dbRecordAttribute *pattribute; - if (!precordType) return S_dbLib_recordTypeNotFound; + if (!precordType) + return S_dbLib_recordTypeNotFound; + pattribute = (dbRecordAttribute *)ellFirst(&precordType->attributeList); while (pattribute) { int nameLen = strlen(pattribute->name); int compare = strncmp(pattribute->name, pname, nameLen); - int ch = pname[nameLen]; + if (compare == 0) { - if (!(ch == '_' || isalnum(ch))) { + int ch = pname[nameLen]; + + if (ch != '_' && !isalnum(ch)) { + /* Any other character can't be in the attribute name */ pdbentry->pflddes = pattribute->pdbFldDes; pdbentry->pfield = pattribute->value; *ppname = &pname[nameLen];