Changelog
Source:NEWS.md
dparser 1.3.2
-
buf_read()(and thereforesbuf_read()) is hardened in three ways without changing itsint *lenABI:- Files larger than
INT_MAX - 2bytes are now rejected with-1instead of silently truncatingoff_t -> intand producing a negative*lenthat the rest of the function then misused as a buffer size. Verified: a 3 GiB sparse file used to SIGSEGV inbuf_readat(*buf)[real_size] = 0; after the fix it returns-1cleanly. -
read()’sssize_treturn is now stored inssize_t, notsize_t. On aread()error (returning-1), the previous code would index(*buf)[SIZE_MAX]— heap corruption. The new code frees the buffer and returns-1. -
if (fd <= 0)->if (fd < 0)so that fd0is treated as a valid descriptor (it is the stdin slot, returned byopen()if stdin has been closed).
- Files larger than
d_pass(D_Parser*, D_ParseNode*, int pass_number)now rejects negativepass_numbervalues explicitly. Previously the bound check was upper-only (pass_number >= npasses), so a negative argument fell through to&p->t->passes[pass_number]and a subsequentpp->kindread landed before thepasses[]array — typically a SIGSEGV, occasionally a silent garbage dispatch. The fix adds the matching lower bound; the function now callsRf_error("bad pass number: %d")for any negative argument.udparse()(and therefore thedparse()legacy wrapper) now returnsNULLwhen called with aNULLbuffer. Previously aNULLbufwas forwarded intoexhaustive_parse, where the scanner dereferenced it (*sinsidewhite_space) and crashed. The new guard at the top ofudparseshort-circuits the call before any state is touched.new_D_Parser()now rejects a negativesizeof_ParseNode_User. Previously a negative argument was stored verbatim, then the per- PNode allocation inmake_PNodeuint l = sizeof(PNode) - sizeof(d_voidp) + sizeof_user_parse_nodeunderflowed to a small value, and the rest ofmake_PNodewrote past the resulting tiny buffer. valgrind on the pre-fix build reported 281 invalid writes of size 8, all rooted inmake_PNode (parse.c:965). After the fix,new_D_ParsercallsRf_errorwith a clear message; valgrind reports 0 errors.-
dparse_sexp()(the entry point used by every per-grammardparse_<gram>()wrapper) now reads its input file throughbuf_read()instead ofsbuf_read() + strlen(). Two bugs are fixed:- If the input file could not be opened,
sbuf_read()returnedNULL, and the subsequentstrlen(NULL)was an immediate SIGSEGV. The new path raisesRf_error("could not read grammar input file: '<path>'"). - For input >= 2 GiB,
strlen()(which returnssize_t) was narrowed to theint buf_lenparameter of legacydparse(), silently truncating to a negative value. The new path uses the length returned bybuf_read()directly and forwards it toudparse()(fullunsigned intrange). Oncebuf_read()is itself promoted tosize_t(separate fix), the path will safely handle inputs up toUINT_MAX.
- If the input file could not be opened,
-
Add
udparse(D_Parser*, char *buf, unsigned int buf_len)as a memory-safe alternative todparse(D_Parser*, char *buf, int buf_len). Existing callers ofdparsestill compile and link unchanged; the ABI ofdparseis preserved. Internally,dparsenow rejects negativebuf_len(returnsNULL) and forwards positive values toudparse, which holds the actual parser implementation.Previously, callers had to cast
strlen(buf)toint, which silently truncated to a wrong (often negative) value when the input exceededINT_MAXbytes; that negative length then propagated intop->end = buf + buf_len, making the parser read random memory before the buffer.New code should call
udparse(p, buf, (unsigned int)strlen(buf))to avoid the cast and safely accept inputs up toUINT_MAXbytes. Both functions are exported and registered viaR_RegisterCCallableand re-declared in the consumer headers (src/dparse.h,src/dparser.h,src/dparser2.h,src/dparserPtr.h).
dparser 1.3.1-12
CRAN release: 2024-09-17
Changed language access to not use
SET_TYPEOF(as required by CRAN)Changed compilation to use strict headers, as requested by CRAN.
Changed interface so that functional changes will not cause segmentation faults when other libraries are not recompiled against this library (removed binary linkage). However changes to the dparser parsing C structures will likely cause a segmentation fault. Since the structures have not changed very much over time, but CRAN requests small changes to the functions frequently, this will probably be sufficient for most cases.
dparser 1.3.1-11
CRAN release: 2023-12-07
Changed
gram.cto handle NULL strings without printing them (as requested by CRAN)Changed
util.cto avoid security warnings for error/warnings in R (as requested by CRAN)Parsing errors during
dparser()evaluation now give the line number for the error.
dparser 1.3.1-10
CRAN release: 2023-03-16
- added
dparser2.hthat declares functions instead of defines them.
dparser 1.3.1-9
CRAN release: 2022-11-10
Initialized version string to zero length string to fix valgrind issues
Change flags to suppress false positive memory leaks (might be lost errors)
dparser 1.3.1-8
CRAN release: 2022-10-29
- Removed all
sprintfas indicated by some new Mac M1 checks forrxode2.
dparser 1.3.1-7
CRAN release: 2022-10-09
- Fixed one remaining strict typing issue, as requested by CRAN.
dparser 1.3.1-6
CRAN release: 2022-10-05
- Updated dparser header to have strict typing, as requested by CRAN.
dparser 1.3.1-4
CRAN release: 2021-04-07
- Updated dparser to explicitly include R headers in the generated grammars (when requested), which should fix the fedora problem
dparser 1.3.1-3
CRAN release: 2021-04-06
- Updated R dparser to use
system()instead ofdo.call("system",...) - Changed default compile to show the
stderrandstdout