SimSelect.c: fix theoretical potential to write to .rodata string

We make a copy of readonly string on function entry and use that instead.
strrchr() is a bit of an annoying API, takes const char* but returns char*
but it is the same string.  One for static analysis or C++.

SimSelectArea() argument unused.
This commit is contained in:
Darryl L. Miles
2025-10-03 23:42:55 +01:00
parent 4d58789c69
commit dd8b5af5ad
+4 -2
View File
@@ -259,7 +259,7 @@ simFreeNodeEntry(
TileListElt *
SimSelectArea(
const Rect *rect)
const Rect * __unused__(rect))
{
int plane;
int SimSelectFunc(Tile *tile, ClientData cdata); /* cb_database_srpaintarea_t (TileListElt **pHead) */
@@ -445,6 +445,7 @@ SimSelection(
static const char QUESTstring[] = "?";
char timeString[256];
char questString[2];
TileListElt *current, *node_list;
char *replyLine;
char *strPtr;
@@ -453,6 +454,7 @@ SimSelection(
extern void RsimErrorMsg(void);
timeString[0] = 0;
strcpy(questString, QUESTstring); /* writable form */
/* check to see if Rsim has been started yet */
@@ -521,7 +523,7 @@ the selection.\n");
strPtr = strrchr( replyLine, '=' );
if( strPtr == NULL )
strPtr = QUESTstring;
strPtr = questString;
else if( coord )
{
*strPtr = '\0';