View Issue Details

IDProjectCategoryView StatusLast Update
0009549Multi Theft Auto : San AndreasMulti Theft Auto : San Andreaspublic2017-06-29 00:47
ReporterSHC//Sniper Assigned Toccw  
Status resolvedResolutionfixed 
Product Version1.5.3 
Target Version1.5.4Fixed in Version1.5.4 
Summary0009549: Erroneous fromJSON parsing

Check the example below. "^T^0" is parsed as a table for some reason which recently broke one of our resources. Replacing "^T^0" with "^T^1" returns nil on the other hand. Changing the string to anything other than "^T^0^" or similar fixes the problem.

Steps To Reproduce

srun tb = fromJSON('[ [ 2251, "^The^ Winners^", "^T^0", 2, 0, 0, 0, [ 102, 153, 204 ], "WRITE SOMENTHING YOU ABOUT\n\n" ] ]')

srun tb[3]

Command results: table: 0x653aa35a53c0 [table]

srun tb = fromJSON('[ [ 2251, "^The^ Winners^", "^T^1", 2, 0, 0, 0, [ 102, 153, 204 ], "WRITE SOMENTHING YOU ABOUT\n\n" ] ]')

srun tostring(tb[3])

Command results: nil [string]

TagsNo tags attached.



2017-02-18 20:13

reporter   ~~0025675

Last edited: 2017-02-18 20:21

This actually gets even funnier - it is not just a random (new) table, it is a pointer to the same table which it resides in.

srun tb
Command results: table: 1B474090 [table]

srun tb[3]
Command results: table: 1B474090 [table]

srun tb[3][3][3][3][3][3][3][3][3][3][3]
Command results: table: 1B474090 [table]

I'm going to look into it.


2017-02-20 23:44

reporter   ~~0025677

Last edited: 2017-02-20 23:53

Okay, after some digging I've found out that ^T^, ^E^ and ^R^ are special internal sequences used for serialization of elements, tables and resources.

If you run: srun tb = fromJSON('[ [[123], "^T^1" ] ]')
then tb[2] will be pointer to [123] table and so on.

Make sure that strings in your JSON don't start with those sequences, or else you may run into further issues.

Currently I don't have enough knowledge to come up with any reasonable solution, but this behaviour is undocumented and potentially dangerous.


2017-02-27 01:03

reporter   ~~0025687

Is there really no way to solve this problem? FromJSON is used by many servers to store data (including user generated content). This bug can potentially be utilized to break people's resources on purpose. In our case an entire core resource was malfunctioning. We can block these internal sequences ourselves but the thousands of other servers will not be aware of this issue/risk.


2017-02-27 15:20

administrator   ~~0025688

Bodged in

Issue History

Date Modified Username Field Change