EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: [Bug 1941875] [NEW] Buggy warning message "Record/Alias name '...' should not contain non-printable ...
From: Dirk Zimoch via Core-talk <core-talk at aps.anl.gov>
To: core-talk at aps.anl.gov
Date: Fri, 27 Aug 2021 09:31:46 -0000
Public bug reported:

There are multiple bugs in dbRecordNameValidate()
(modules/database/src/ioc/dbStatic/dbLexRoutines.c).

/* any character restrictions */
char c = *pos;
[...]
if(c < ' ') {
  errlogPrintf("Warning: Record/Alias name '%s' should not contain non-printable 0x%02u\n",
                         name, (unsigned)c);
}

1. The check for non-printable characters: if(c < ' ') does not consider implementations where char is signed. Characters with the high bit set are considered negative and thus <' '.
2. Printing the character with "0x%02u" prints a decimal number prefixed with 0x which is confusing (not to say wrong).
3. Casting a signed char to unsigned effectively first sign extends the char to int, then re-interprets it as unsigned int, turning a char >0x80 into a number >4294967168.
On an implementation where char is unsigned, the whole casting is pointless anyway.

This results in confusing warnings like:
Warning: Record/Alias name 'Ä' should not contain non-printable 0x4294967235

The function should explicitly use unsigned char c to fix (c < ' '), use
"0x%02x" to format c and not cast c.

** Affects: epics-base
     Importance: Undecided
         Status: New

** Patch added: "dbLexRoutines.patch"
   https://bugs.launchpad.net/bugs/1941875/+attachment/5521157/+files/dbLexRoutines.patch

-- 
You received this bug notification because you are a member of EPICS
Core Developers, which is subscribed to EPICS Base.
Matching subscriptions: epics-core-list-subscription
https://bugs.launchpad.net/bugs/1941875

Title:
  Buggy warning message "Record/Alias name '...' should not contain non-
  printable ...

Status in EPICS Base:
  New

Bug description:
  There are multiple bugs in dbRecordNameValidate()
  (modules/database/src/ioc/dbStatic/dbLexRoutines.c).

  /* any character restrictions */
  char c = *pos;
  [...]
  if(c < ' ') {
    errlogPrintf("Warning: Record/Alias name '%s' should not contain non-printable 0x%02u\n",
                           name, (unsigned)c);
  }

  1. The check for non-printable characters: if(c < ' ') does not consider implementations where char is signed. Characters with the high bit set are considered negative and thus <' '.
  2. Printing the character with "0x%02u" prints a decimal number prefixed with 0x which is confusing (not to say wrong).
  3. Casting a signed char to unsigned effectively first sign extends the char to int, then re-interprets it as unsigned int, turning a char >0x80 into a number >4294967168.
  On an implementation where char is unsigned, the whole casting is pointless anyway.

  This results in confusing warnings like:
  Warning: Record/Alias name 'Ä' should not contain non-printable 0x4294967235

  The function should explicitly use unsigned char c to fix (c < ' '),
  use "0x%02x" to format c and not cast c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/epics-base/+bug/1941875/+subscriptions


Replies:
[Bug 1941875] Re: Buggy warning message "Record/Alias name '...' should not contain non-printable ... mdavidsaver via Core-talk
[Bug 1941875] Re: Buggy warning message "Record/Alias name '...' should not contain non-printable ... mdavidsaver via Core-talk
[Bug 1941875] Re: Buggy warning message "Record/Alias name '...' should not contain non-printable ... mdavidsaver via Core-talk
[Bug 1941875] Re: Buggy warning message "Record/Alias name '...' should not contain non-printable ... Andrew Johnson via Core-talk

Navigate by Date:
Prev: [Bug 1935037] Re: Invalid charactor in field name Ralph Lange via Core-talk
Next: [Bug 1935037] Re: Invalid charactor in field name Dirk Zimoch via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: [Bug 1941770] Re: Base-3.15.9 tarfile is missing the startup directory Andrew Johnson via Core-talk
Next: [Bug 1941875] Re: Buggy warning message "Record/Alias name '...' should not contain non-printable ... mdavidsaver via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 11 Oct 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·