From b399794a531d5d0080d9f983b05c4b8a62baf195 Mon Sep 17 00:00:00 2001 From: Kp Date: Mon, 18 Nov 2019 00:22:34 +0000 Subject: [PATCH] Remove test for unconverted characters after a superx= line Historically, Descent ignored any trailing unconverted characters. The logic in Descent 1 was tightened in 3368390f37c6, and then the logic in Descent 2 was made to mirror Descent 1 in 19699037ced5. Restore the lax parsing logic in both games. Reported-by: InsanityBringer (issue 5) Fixes: 3368390f37c695879f06e89d9ceae8ee275cdc56 ("Check for valid SuperX number") (for Descent 1) Fixes: 19699037ced5bb2ef5745687403b445c5b68da51 ("Move d2x-rebirth/main/bmread.cpp -> similar/main/bmread.cpp") (for Descent 2) --- similar/main/bmread.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/similar/main/bmread.cpp b/similar/main/bmread.cpp index 7bec8d550..9578f1977 100644 --- a/similar/main/bmread.cpp +++ b/similar/main/bmread.cpp @@ -568,10 +568,11 @@ int gamedata_read_tbl(d_vclip_array &Vclip, int pc_shareware) SuperX = -1; if ( (temp_ptr=strstr( inputline, "superx=" )) ) { - char *p; - const auto s = strtol(&temp_ptr[7], &p, 10); - if (!*p) - SuperX = s; + /* Historically, this was done with atoi, so the input + * source was allowed to have unconvertible characters. + * Accept such lines by ignoring any trailing content. + */ + SuperX = strtol(&temp_ptr[7], nullptr, 10); #if defined(DXX_BUILD_DESCENT_II) Assert(SuperX == 254); //the superx color isn't kept around, so the new piggy regeneration