Project:
RSS

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009549New issuesMulti Theft Auto : San Andreaspublic2017-02-16 13:372017-02-27 15:20
ReporterSHC//Sniper 
Assigned Toccw 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Summary0009549: Erroneous fromJSON parsing
DescriptionCheck 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 Reproducesrun 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.
Attached Files

- Relationships

-  Notes
(0025675)
pkpawelo (viewer)
2017-02-18 20:13
edited on: 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.

(0025677)
pkpawelo (viewer)
2017-02-20 23:44
edited on: 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.

(0025687)
SHC//Sniper (reporter)
2017-02-27 01:03

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.
(0025688)
ccw (administrator)
2017-02-27 15:20

Bodged in https://github.com/multitheftauto/mtasa-blue/commit/859e10026ba6efc1762886a190be41680dc746a0 [^]

- Issue History
Date Modified Username Field Change
2017-02-16 13:37 SHC//Sniper New Issue
2017-02-18 20:13 pkpawelo Note Added: 0025675
2017-02-18 20:21 pkpawelo Note Edited: 0025675 View Revisions
2017-02-20 23:44 pkpawelo Note Added: 0025677
2017-02-20 23:48 pkpawelo Note Edited: 0025677 View Revisions
2017-02-20 23:53 pkpawelo Note Edited: 0025677 View Revisions
2017-02-27 01:03 SHC//Sniper Note Added: 0025687
2017-02-27 15:20 ccw Note Added: 0025688
2017-02-27 15:20 ccw Status new => resolved
2017-02-27 15:20 ccw Resolution open => fixed
2017-02-27 15:20 ccw Assigned To => ccw


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker