]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commit - src/rrd_rpncalc.c
Don't crash on invalid variable names in RPN 677/head
authorSebastian Schmidt <yath@yath.de>
Sun, 18 Oct 2015 17:15:37 +0000 (19:15 +0200)
committerSebastian Schmidt <yath@yath.de>
Mon, 19 Oct 2015 13:48:50 +0000 (15:48 +0200)
commit0c3e8dbd6a3be9736d87ac64cf82956c2a5fd62e
tree656a6787d4e42fe4014b02a607f51d8b91a2d22b
parent8b9f92765879fb1ef3bad99dd8f6a11905a1a3be
Don't crash on invalid variable names in RPN

When rpn_parse() finds [^\0,] after parsing a token, it returns NULL
without setting an error. This causes rrd_test_error() to return false
and subsequent code will dereference NULL (cf. rrdtool xport
CDEF:foo=foo-bar).

This commit changes the OP_VARIABLE branch in rpn_parse so that in order
to be a variable name, sscanf needs to match the full name, causing a
more meaningful "ERROR: don't understand 'illegal-variable-name'" error
message in that case. Also, I made the return NULL branch set an error
message so rrd_test_error() will succeed.
src/rrd_rpncalc.c