Invalid memory read in dbGetAttributePart

Bug #1479330 reported by Ambroz Bizjak
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Status tracked in 7.0
3.14
Fix Released
Undecided
Andrew Johnson
3.15
Fix Released
Undecided
Andrew Johnson
3.16
Fix Released
Low
Andrew Johnson
7.0
Fix Released
Low
Andrew Johnson

Bug Description

There is a possibility of an invalid memory read in dbGetAttributePart. The value of pname[nameLen] is taken before it is certain that there are at least nameLen (non-null) characters in pname (which is indicated by compare==0). I have found this with Address Sanitizer.

Patch is attached. With this fix I see no other ASan errors.

Revision history for this message
Ambroz Bizjak (ambroz-bizjak) wrote :
Revision history for this message
Ambroz Bizjak (ambroz-bizjak) wrote :

3.14, 3.15 and 3.16 all appear to be affected.

Andrew Johnson (anj)
Changed in epics-base:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Andrew Johnson (anj)
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

So it looks like this bug happens (at least) whenever dbNameToAddr() is called with an invalid field name shorter than 4 charactors (the default attributes are "RTYP" and "VERS"). For example, "record.Q" for an aiRecord.

Changed in epics-base:
importance: Low → High
assignee: Andrew Johnson (anj) → mdavidsaver (mdavidsaver)
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

oh, great. Another LP collision.

Revision history for this message
Andrew Johnson (anj) wrote :

I agree this is a bug that needs fixing, but I can't apply your patch directly (see below). I am making equivalent changes though. That code isn't the easiest to understand, so I'll clarify what the routine is doing while I'm at it.

* The use of the int variable ch or a cast of pname[nameLen] to (int) is needed to prevent warnings on some compilers, which complain if you pass isalnum() a char.
* Your patch also clashes slightly with a recently applied change that fixed other issues in the dbGetAttributePart() routine.

I'm fixing this on the 3.14 branch; the change will percolate up to the other branches when I merge them up in due course.

Thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.