dMZX Forums: if command checks if the first argument is a string before tr_msg -> Archived MegaZeux Bugs -> Tracker

Jump to content

Report ID 770 Title if command checks if the first argument is a string before tr_msg
Product Archived MegaZeux Bugs Status Fixed (Severity 3 - Medium)
Version 2.91j Fixed in 2.92
Introduced In Version <2.80Operating System All platforms

Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Report ID #770: if command checks if the first argument is a string before tr_msg

#1 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 26 June 2019 - 01:28 AM

The if command doesn't resolve the first name provided to it before checking if it's a string, which can result in both false negatives for the check (when interpolating a string index into the string name, introduced in 2.62; when interpolating a string starting with a '$' as the start of the string name, introduced in 2.62) and false positives (when interpolating a string splice into the name of an index/length check, introduced in 2.84 to fix a different manifestation of this problem). In all cases, this check won't work as expected.

The only other affected situation in run_robot is copy block X Y W H $string T. The set/inc/dec commands, placing string MZMs, loading string charsets, loading string palettes, and saving string MZMs are not affected by this, as they perform tr_msg before checking if any relevant params are a string.

Examples:

False negative when interpolating a string index into the name (string_type/is_string checks for a . anywhere to determine if it's an index):
set "$string1.0" to 9
set "$string&$string1.0&" to "a"

if "$string&$string1.0&" = "a" then "ok"
* "oh no"
end
: "ok"
* "ok"


False negative when interpolating a string starting with '$' as the start of the name (the '$' at the start isn't present until after tr_msg):
set "$string1" to "_string2"
set "$string1.0" to 36
set "$string2" to "test"
set "test" to 12345

if "&$string1&" = "test" then "ok"
* "oh no"
end
: "ok"
* "ok"


Note that the expected behavior above WORKS for the second param of the check as long as the first param starts with a $. This also works with the the set command starting from 2.68, i.e. this code displays "test" in all versions including and after 2.68, so the behavior above should be valid:
set "$string1" to "_string2"
set "$string1.0" to 36
set "&$string1&" to "test"
* "&$string2&"


False positive when interpolating an offset/limit/splice into the name (is_string stops checking for a . at the first + or #):
set "$" to "test"
set "$testtest" to "a"

if "$test&$&.0" = 97 then "ok"
if "$test&$#4&.0" = 97 then "ok"
* "oh no"
end
: "ok"
* "ok"


The if command could probably be fixed pretty easily and I doubt this needs a compatibility check, but copy block $string looks a little more annoying to fix due to the very specific way its params are evaluated (fixing this would involve changing the way and order they're evaluated in this specific case, which probably isn't as big a deal as it sounds).

I haven't tried to determine if anywhere outside of run_robot is affected by this, but I doubt it. Edit: expr.c; all cases there appear to properly handle this.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository


Page 1 of 1  
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Replies (1 - 2)

#2 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 30 June 2019 - 06:05 AM

Updating status to: Fixed
Issue fixed in: 2.92

Fixed in GIT 46799b83.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#3 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,960
  • Joined: 12-October 00
  • Gender:Male

Posted 23 July 2019 - 12:36 AM

Moving to: Archived MegaZeux Bugs


Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

1 User(s) are reading this issue
1 Guests and 0 Anonymous Users


Powered by IP.Tracker 1.3.2 © 2026  IPS, Inc.