ingwarsw / tinyfugue

TinyFugue - Rebirth
Other
58 stars 33 forks source link

Color crash bug #40

Closed warmstarter closed 3 years ago

warmstarter commented 3 years ago

Found an easy way to crash TinyFugue.

This would be a pretty standard way to set colors in my status bar:

/set vw_tablist_fg_world_attrs=@{Cyellow,Cbgrgb001}

But if I just set it to a non-existent color:

/set vw_tablist_fg_world_attrs=@{Ctestyellow,Cbgrgb001}

And then change my fgworld to trigger the color change in the status bar, TF dumps core. Presumably similar would happen with any way of setting that invalid color. Looks like colors are just being passed for evaluation rather than sanity checked.

Haven't yet tested if I can get a MUSH to remotely crash TF with this bug, but seems likely.

warmstarter commented 3 years ago

Looks like this is a bit more complex, but possibly more widespread.

Standard status_attr gives an error for a bad color.

Here are the lines that seem to be the most likely cuplrits, looking like the issue is in decode_attr(), str*(), or substr(). Need to do some investigation there.

If you want to try it, the relevant code is in my scripts directory, you'll need vwstatus.tf (most likely culprit), vworld.tf, status.tf, and socket.tf

https://github.com/warmstarter/tinyfugue-scripts

/test _ret_item := strcat(_ret_item, vw_tablist_fg_world_attrs)
       /test _dret:=decode_attr(_ret) %;\
        /test _avail_len:=vw_get_tablist_size() %;\
        /if (strlen(_dret) > _avail_len) \
                /if (vw_exists(fg_world())) \
                        /test _fg_loc:=strstr(_dret, vw_tab_name(fg_world())) %;\
                /else \
                        /test _fg_loc:=strstr(_dret, fg_world()) %;\
                /endif %;\
                /test _cutoff:=strchr(_dret, "|[", _fg_loc - _avail_len/2 > 0 ? _fg_loc - _avail_len/2 : 0) %;\
        /else \
                /test _cutoff:=0 %;\
        /endif %;\
        /return tolower(substr({_dret}, _cutoff))
warmstarter commented 3 years ago

Here it is .....

/eval /set colorcrash=@{CbgblackCRASH}Crash!
/test colorcrash := decode_attr(colorcrash)
warmstarter commented 3 years ago

Ok, here's a hint, this also works. Given that the @{ is unmatched, it shouldn't even be attempting anything.

/eval /set colorcrash=@{CbgblackCRASH
/test colorcrash := decode_attr(colorcrash)
warmstarter commented 3 years ago

https://pastebin.com/JxsizRcG

warmstarter commented 3 years ago

This is fixed in #38