Module Name: src Committed By: kre Date: Sat Aug 3 03:46:23 UTC 2024
Modified Files: src/bin/sh: histedit.c Log Message: Revert a part of a change made on 1999-07-09 (in rev 1.21). That change ("compile with WARNS = 2") added "const" qualifiers in many places. One of them, in this file, became a const char *, which needed to be passed to sh function defined as taking a char * arg. (evalstring()). To do that safely (in 1999), a copy of the original string was made, and that copy was passed to evalstring() instead of the original. The copy is simply char *, and if something altered it, no-one would care. The original string (in some cases) must not be altered. That was the cause of the bug fixed (a different way) in the previous commit to this file. To copy the string, space needed to be allocated, and when that was done, if the string was just (the right length, its terminating \0 (which previously was stored outside the string itself) and if the current shell stack memory block was big enough that a new one wasn't needed, the \0 would be trampled (then the strcpy() would become overwriting, and havoc result). Now evalstring() has been updated to take a const char *, and the string passed to it truly is treated as const data (nothing ever attempts to alter it) so making a copy of the string isn't needed, and we can go back to the way the code used to be, pre-1999. That is, modulo other unrelated changes (or one change actually) that has been made since, which has nothing to do with the issues here. The change made in the previous revision could be undone, but won't be, as it is logically the right thing to do. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/bin/sh/histedit.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.