From da216195b33fbb1cd917bf670f4faf6255907d0d Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 3 Oct 2025 23:08:39 +0100 Subject: [PATCH] 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. --- sim/SimSelect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sim/SimSelect.c b/sim/SimSelect.c index 65714470..a331c92a 100644 --- a/sim/SimSelect.c +++ b/sim/SimSelect.c @@ -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';