Commit Graph
1556 Commits
Author SHA1 Message Date
Jacqueline GarrahanandClaude Opus 4.8 fde8e4ca2e histogramRecord: fix heap OOB write when SGNL approaches ULIM
The bin-search loop in add_count() assumes nelm*wdth == ulim-llim, but
wdth is a rounded quotient so nelm*wdth can be strictly less than
ulim-llim.  A SGNL value just below ULIM then leaves the loop with
i == nelm+1, and pdest = bptr + nelm writes one epicsUInt32 past the
nelm-element buffer.  This is reachable over Channel Access by putting a
value near ULIM to the SGNL field (special SPC_MOD).  Clamp the index to
nelm.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 14:17:43 -05:00
Sang Woo Kim 484eab57c9 rsrv: reject a non-finite beacon period
The beacon-period gate in online_notify already rejected a parse
failure and a non-positive value, but epicsScanDouble parses "nan" and
"inf", and maxPeriod<=0.0 is false for both, so a non-finite period
reached the beacon delay loop. A NaN maxdelay makes delay<maxdelay
false forever, pinning the beacon interval at the 0.02 s startup value
- a ~50 Hz beacon flood on every configured interface; an infinite
maxdelay lets the doubling delay grow without bound, silencing beacons
entirely.

Gate on finite() (from epicsMath.h), matching the client-side
EPICS_CA_MAX_SEARCH_PERIOD handling in udpiiu.cpp, and name the actual
problem in the diagnostic instead of "float fetch failed" (the message
already covered the non-positive case, which is not a fetch failure).
2026-07-21 14:15:43 -05:00
Sang Woo Kim 2ab1bb14c5 calcRecord: drop unhandled special(SPC_MOD) from INPM..INPU
INPM..INPU each declared special(SPC_MOD), but calcRecord's special()
only implements SPC_CALC and returns S_db_badChoice for anything else.
Every dbPutField/caput to one of those nine link fields therefore ran
special(after=TRUE), hit the fall-through, and failed with
S_db_badChoice ("bad special value") -- nine documented input links
were unwritable at run time.

The twelve sibling links INPA..INPL carry no special and accept writes,
and calcRecord (unlike calcoutRecord) does no run-time link
re-initialization, so there is no handler for SPC_MOD to reach. Remove
the erroneous attribute from the nine fields so they match INPA..INPL;
special() then runs only for CALC, which is the only field that still
carries a special.
2026-07-21 14:15:43 -05:00
Sang Woo Kim ce775a80cf udpiiu: reject a non-finite or non-positive EPICS_CA_MAX_SEARCH_PERIOD
epicsScanDouble accepts "inf" and "nan", so envGetDoubleConfigParam
returns success for them and the parsed value flows into getMaxPeriod's
only range gate, maxPeriod < maxSearchPeriodLowerLimit. That comparison
is false for both inf and NaN, so a non-finite period reaches
getNTimers(), whose static_cast<unsigned> of 1 + log(maxPeriod/...)/log2
is an undefined float->unsigned conversion: inf aborts the client in
malloc via a garbage nTimers allocation, and NaN drives the search-timer
wheel off a NaN period where every deadline comparison is false.

Gate the parsed value on finite() (from epicsMath.h) and positivity
alongside the parse status, and fall back to the default period. A
non-positive period is not a "low" period to be clamped up to the 60 s
lower limit; it takes the same invalid-input path as inf/NaN.

getMaxPeriod() is getNTimers()'s only caller, so this makes the
conversion finite and positive by construction.
2026-07-21 14:15:43 -05:00
Sang Woo Kim a8180003e9 cac: reject a non-positive or non-finite EPICS_CA_CONN_TMO
A successful parse of EPICS_CA_CONN_TMO stored the value into connTMO
unchecked, so EPICS_CA_CONN_TMO=-5 or =0 left the connection-verify
watchdog deadline permanently in the past. The watchdog then fires
continuously, flooding stderr with "Virtual circuit unresponsive" and
pinning a CPU while updates still arrive. NaN and inf (which
epicsScanDouble also accepts) slip past any ordering comparison: a NaN
period leaves the watchdog deadline arithmetic undefined, and an
infinite period silently disables circuit verification.

Fold the validity check into the existing parse-failure branch, so an
unparsable, non-finite, or non-positive value takes the same path:
warn once and fall back to the 30 s CA_CONN_VERIFY_PERIOD default.
This mirrors the sibling EPICS_CA_MAX_ARRAY_BYTES handling a few lines
below, which already gates a parse failure and an out-of-range value
in one condition, and matches the finite() gate on
EPICS_CA_MAX_SEARCH_PERIOD in udpiiu.cpp.
2026-07-21 14:15:43 -05:00
Jacqueline GarrahanandClaude Opus 4.8 ae029e46a5 printfRecord: fix one-byte VAL overflow in %ls conversion
In the long-string (%ls) branch dbGetLink(DBR_CHAR) / dbLoadLinkLS can
leave n at vspace+1, so pval[n] = 0 writes at pval[vspace+1], one byte
past the sizv-byte VAL buffer (pval + vspace + 1 == prec->val + sizv).
Clamp n to vspace immediately before writing the terminator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 07:53:37 -05:00
Michael Davidsaver 7dc46f2168 caget missing NULL check 2026-07-21 07:48:23 -05:00
Jacqueline GarrahanandClaude Opus 4.8 50f4eaa9c0 iocsh: fix inverted parse test in 'on error wait <delay>'
epicsParseDouble returns 0 on success and non-zero on failure, but the
branches were swapped: a valid delay printed "Invalid 'on error wait'
delay" and the usage text, while an invalid delay was silently accepted
with timeout forced to 5.0.  Report the error on parse failure and accept
the value on success.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 17:24:44 -05:00
Jacqueline GarrahanandClaude Opus 4.8 9cd87f21aa dbConvert: fix UInt64->String conversion truncating to 32 bits
putUInt64String used cvtUlongToString, which is cvtUInt32ToString, so the
64-bit source was narrowed to its low 32 bits (e.g. 0x1_0000_0007 printed
as "7").  Use cvtUInt64ToString, matching getUInt64String and every other
width-specific putXxxString.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 09:49:36 -05:00
Sang Woo Kim b03213ea7a seqRecord: fix upper display limit of the DLYn fields
get_graphic_double() assigns lower_disp_limit twice and never writes
upper_disp_limit, so a DBR_GR_DOUBLE read of any DLYn field reports
the inverted range lower=10, upper=0.  The second assignment was
evidently meant for the upper limit; the 0 in the upper slot is the
zeroed buffer dbAccess.c hands to the RSET, not a chosen value.

Both assignments date from commit 27e80be2e5 which introduced the
DLYn limits, so every release since 3.14.11 reports the inverted
range over both CA (DBR_GR/CTRL) and PVA (display.limitLow/High).

Extend seqTest with a DBR_GR_DOUBLE read of DLY0; the new cases
fail with lower=10, upper=0 before this fix.
2026-07-20 09:34:30 -05:00
Jacqueline GarrahanandClaude Opus 4.8 00173ac03c dbJLink: fix assignment-instead-of-compare in dbJLinkMapAll
The guard used recname[0] = '\0' (assignment) instead of == , which wrote
a NUL into the caller's string, truncating it to "", and evaluated to 0
so recname was left non-NULL pointing at "".  Every record then failed
the name comparison and nothing was mapped.  Use ==, matching dbjlr.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 09:02:37 -05:00
Sang Woo Kim ef06b34ee4 selRecord: fix the precision reported for the A-L and LA-LL fields
get_precision() walks pvalue and plvalue over the A-L and LA-LL fields,
then compares paddr->pfield against &pvalue and &plvalue -- the
addresses of the two local pointer variables, not of the fields they
point at.  Those are stack addresses, so neither test has ever matched
and every A-L or LA-LL precision request falls through to
recGblGetPrec().  The line just above gets it right: prec->val is a
field and needs the &, whereas pvalue and plvalue are already pointers.

Both tests date from e87551df24, the commit that added the loop, and
have been dead ever since, so every release since R3.12 has this.  They
carried a (void *) cast until 6d85a36397 removed it, which is why the
compiler was never shown a double ** to complain about.  That the
fields were meant to be covered is not in doubt: this record's
get_graphic_double() and get_control_double() both name A-L and LA-LL.

This changes what those fields report.  recGblGetPrec() substitutes 15
for a DOUBLE precision outside 0 to 15, so today A-L and LA-LL answer
15 for a PREC of 17 while VAL answers 17.  They now answer PREC
unclamped, which is what VAL has always done.

Add selTest, reading the precision of VAL, A, L, LA, LL and HIHI from a
record with PREC=17.  The four A-L and LA-LL cases report 15 before
this fix; VAL and HIHI pin the two paths either side of them.
2026-07-19 17:21:01 -05:00
Michael Davidsaver 848f121339 rsrv: USE_TYPED_DBEVENT 2026-07-17 14:33:40 -05:00
Jacqueline GarrahanandClaude Opus 4.8 ec0ae7d831 errlog: fix out-of-bounds read when resizing the print buffer
errlogBufResize copied the print buffer from &pvt.print->base (the
address of the char* field inside the buffer_t struct) instead of
pvt.print->base (the buffer it points to), reading bufSize bytes from an
~8-byte struct field.  Drop the stray & so it reads the actual buffer,
matching the adjacent log-buffer copy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-16 16:57:57 -05:00
Andrew Johnson 605542ece7 Release notes, add a drvet to the example template 2026-07-16 16:16:39 -05:00
Andrew Johnson cd6d2ed042 Move -DUSE_TYPED_DRVET to USR_CPPFLAGS
Also fixes an issue in the generated registerRecordDeviceDriver code.
2026-07-16 16:16:39 -05:00
Érico Nogueira b87b6c91ff Fix UAF in caRepeaterThread
The ca_repeater function has some failure cases which can cause it to
return. In such a situation, a reference to the current thread's
epicsThreadId is kept in the taskwd, causing an eventual use-after-free
when the taskwd tries to determine the task's status.

We fix this problem by removing the thread from the taskwd if
ca_repeater ever returns.
2026-07-06 16:29:52 -07:00
Michael Davidsaver cf85a1a5eb rsrv: log_header paddr=
Currently prints dbChannel**
2026-06-24 18:16:55 -07:00
Michael Davidsaver 07da9aeb32 minor 2026-06-24 18:16:55 -07:00
Michael Davidsaver f634d3d885 fix last LOCAL 2026-06-24 18:16:55 -07:00
Jeremy Lorelli 35a91eed8d database: Replace epicsEventMustSignal -> epicsEventMustTrigger in comments 2026-06-24 17:00:30 -07:00
Michael Davidsaver 499fec4120 doc devSup.h 2026-06-21 14:49:25 -07:00
Michael Davidsaver 46ab847d8a Document dbScan.h 2026-06-21 14:23:12 -07:00
Michael Davidsaver db67227a96 dbScan one more NUM_TIME_EVENTS 2026-06-21 09:27:55 -07:00
Michael Davidsaver 45a1edcfac minor 2026-06-21 09:27:55 -07:00
mdavidsaver 4b03e97d7b Embed GDB helper
* Add GDB helper script

Pretty printing of some common argument types

Need to add a line to ~/.gdbinit

> add-auto-load-safe-path /path/to/base/checkout/

afterwards verify at GDB shell with

> info auto-load python-scripts
> info pretty-printer

Tested with GDB 16.3 circa Debian 13

Add $rcast(dbCommon) to up-cast
Add $record("name") to lookup record
Add $elln(ELLLIST,#) to index into list
2026-06-21 07:18:08 -07:00
rhong 987b21f68a Slow search_reply_udp in RTEMS IOCs (#836)
* Use malloc_free_space() instead of malloc_info( &info ) in osiSufficentSpaceInPool
2026-06-18 11:27:53 -05:00
Abdalla Al-Dalleh 678092d033 biRecord.c/boRecord.c: Fix gcc -Wsizeof-pointer-memaccess (#887)
../rec/biRecord.c:191:42: warning: argument to ‘sizeof’ in ‘strncpy’
call is the same expression as the source; did you mean to use the
size of the destination? [-Wsizeof-pointer-memaccess]
  191 |         strncpy(pstring,prec->znam,sizeof(prec->znam));
      |                                          ^

Use memcpy instead of snprintf.

STATIC_ASSERT is added to ensure znam and onam are sized enough.
2026-06-10 09:53:31 -05:00
Michael Davidsaver 7e18b8cff0 asDump* quote UAG and HAG entries 2026-06-07 16:35:25 -07:00
Torsten Bögershausen 87ee088728 dbAccess.c: Improve logging of illegal field_type
Debugging a problem and looking at the message

recGblDbaddrError: dbPut: Request type is 0 Illegal Database Request Type...
does not help very much: request type 0 is a legal value.

Improve the message to show the field type as well:
recGblDbaddrError: dbPut: dbrType = 0 field_type = DBF_INLIK (14)...

Do the same for both dbPut and dbGet.
2026-05-27 09:52:14 -05:00
Simon Rose d1705d46f2 Refactor tests and add test that errlogInit() can be run more than once 2026-05-27 09:50:20 -05:00
Simon Rose 5122fabf74 Add error/warning ANSI prefixes to error/warning messages 2026-05-27 09:50:20 -05:00
Simon Rose c0117c4b1d Add unrelease for errloginit2 change 2026-05-27 09:50:20 -05:00
Simon Rose cb5c540c4e Block resizes from listener callbacks 2026-05-27 09:50:20 -05:00
Simon Rose 8834727b5b Lock buffer size changes while running thread 2026-05-27 09:50:20 -05:00
Simon Rose 70e34a7a2e Call errlogClampConfig only a single time 2026-05-27 09:50:20 -05:00
Simon Rose 73b89cbcd9 Move frees out of mutex lock 2026-05-27 09:50:20 -05:00
Simon Rose a3d76ef8fb Stop flushing the errorlog during init 2026-05-27 09:50:20 -05:00
Simon Rose bf5e39976f Change initial errlogprintfs to printfs
RTEMS performs a few early errlogPrintf calls. This initialises
the errlog buffers to some default values blocking certain tests
from re-initialising the error log later.
2026-05-27 09:50:20 -05:00
Simon Rose 68763a9ae9 Remove errlogBufResize in favour of allowing errlogInit[2] to be called repeatedly 2026-05-27 09:50:20 -05:00
Simon Rose f7c74a04b1 Add warning if errorlog configuration has been clamped 2026-05-27 09:50:20 -05:00
Simon Rose 3b7a5b5106 Make the maximum message size dependent on the buffer size 2026-05-27 09:50:20 -05:00
Simon Rose b334ec80bb Update the error log functionality to avoid losing writes 2026-05-27 09:50:20 -05:00
Simon Rose bb5f12b2fa Add command to show errlog buffer contents 2026-05-27 09:50:20 -05:00
Simon Rose a03d1fbe45 Add commandline utility to resize buffer after being initialised 2026-05-27 09:50:20 -05:00
Simon Rose 6b80b0cfb9 Modify errorlog initialisation to add separate default value 2026-05-27 09:50:20 -05:00
Michael Davidsaver 2f20e78e43 epicsStrPrintEscaped() operate on unterminated string
see 3a2d225682
see f488765631
2026-05-14 08:44:38 -07:00
Michael Davidsaver 8bfe89b57d doc dbBase.h
document dbBase list node types
2026-05-12 18:50:54 -07:00
Andrew Johnson b5434c1e6b Error message fixes/improvements 2026-04-15 10:09:52 -05:00
Michael Davidsaver ef48298294 dbCa: iocInit wait for all conditions
After connectCallback, need to wait for up to three
concurrent actions.  Native and string subscriptions,
as well as GET of metadata.

Complicated because event_handler_args does not identify
the evid.

see 717d69e1fc
2026-04-15 10:05:07 -05:00