Add more to a warning
[gh-bc.git] / MEMORY_BUGS.md
blob2e41ad3d75c9459d4aabb2faafa1ebba8775d976
1 # Memory Bugs
3 This is a list of all of the memory bugs that were found in *released* versions
4 of `bc`, `dc`, or `bcl`. (Non-released commits with memory bugs do not count.)
6 I made this list for two reasons: first, so users can know what versions of
7 `bc`, `dc`, and `bcl` have vulnerabilities, and two, I once had a perfect record
8 and then found a couple, but forgot and claimed I still had a perfect record
9 right after, which was embarrassing.
11 This list is sorted by the first version a bug exists in, not the last it
12 existed in.
14 * In versions `1.1.0` until `6.2.0` (inclusive) of `bc` and `dc`, there is a
15   out of bounds read and write in history when pressing ctrl+r (or any other
16   unused letter) then inserting two characters.
18   The first version without this bug is `6.2.1`.
20 * In versions `3.0.0` until `6.0.1` (inclusive) of `bc` and `dc`, there is a
21   double-free on `SIGINT` when using command-line expressions with `-e` and
22   `-f`. This was caused by not properly ending a jump series.
24   The first version without this bug is `6.0.2`.
26 * In versions `3.0.0` until `6.7.5` (inclusive) of `bc` and `dc`, there is a
27   possible out-of-bounds read when there is an error flushing `stdout` on exit
28   because such an error would cause `bc` and `dc` to attempt to use a `jmp_buf`
29   when none exists.
31   The first version without this bug is `6.7.6`.
33 * In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is an
34   out-of-bounds access if a non-local (non-`auto`) variable is set to a string
35   with `asciify()`, then the function is redefined with a use of the same
36   non-local variable.
38   This happened because strings were stored per-function, and the non-local
39   variable now had a reference to the string in the old function, which could be
40   at a higher index than exists in the new function. Strings are stored globally
41   now, and they are *not* freed once not used.
43   The first version without this bug is `6.1.0`.
45 * In versions `5.0.0` until `6.0.4` (inclusive) of `bc`, there is another
46   out-of-bounds access if an array is passed to the `asciify()` built-in
47   function as the only argument. This happened because arrays are allowed as
48   function arguments, which allowed them to be used as arguments to `asciify()`,
49   but they should not have been allowed. However, since they were, the
50   `asciify()` code tried to access an argument that was not there.
52   The first version without this bug is `6.1.0`.
54 * In version `6.0.0` of `bcl`, there are several uses of initialized data that
55   have the same root cause: I forgot to call `memset()` on the per-thread global
56   data. This is because the data used to be *actually* global, which meant that
57   it was initialized to zero by the system. This happened because I thought I
58   had properly hooked Valgrind into my `bcl` tests, but I had not.
60   The first version without this bug is `6.0.1`.
62 * In version `6.0.0` until `6.2.4` (inclusive) of `bcl`, there is a possible
63   use-after-free if `bcl_init()` fails.
65   The first version without this bug is `6.2.5`.