Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"WebStorage" section of config.vdf causes a System.IndexOutOfRangeException #32

Closed
Baguettedood opened this issue Mar 2, 2022 · 7 comments
Labels

Comments

@Baguettedood
Copy link

Attempting to deserialize Steam's "config.vdf" with Gameloop.Vdf when the config.vdf has a "WebStorage" section causes the mentioned exception. Maybe something to do with the egregious amount of backslashes?

Tested on Steam for Linux client built "Feb 22 2022, at 00:40:10".

A trimmed-down example config.vdf is provided:
testconfig.vdf.zip

My code:

namespace vdftest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var vdfpath = Path.Combine("/home/my_username/Projects/vdftest/", "testconfig.vdf");
            var text = File.ReadAllText(vdfpath);
            VProperty volvo = VdfConvert.Deserialize(text);
            Console.WriteLine("Complete");
        }
    }
}

Expected result:

Hello World!
Complete

Actual result:

Hello World!

Unhandled Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at Gameloop.Vdf.VdfTextReader.ReadToken () [0x001ff] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadProperty (Gameloop.Vdf.VdfReader reader) [0x0000d] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadObject (Gameloop.Vdf.VdfReader reader) [0x00035] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadProperty (Gameloop.Vdf.VdfReader reader) [0x00058] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadObject (Gameloop.Vdf.VdfReader reader) [0x00035] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadProperty (Gameloop.Vdf.VdfReader reader) [0x00058] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.Deserialize (System.IO.TextReader textReader) [0x0003c] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfConvert.Deserialize (System.IO.TextReader reader, Gameloop.Vdf.VdfSerializerSettings settings) [0x00014] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfConvert.Deserialize (System.String value, Gameloop.Vdf.VdfSerializerSettings settings) [0x00006] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfConvert.Deserialize (System.String value) [0x00006] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at vdftest.MainClass.Main (System.String[] args) [0x00023] in /home/my_username/Projects/vdftest/vdftest/Program.cs:27 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at Gameloop.Vdf.VdfTextReader.ReadToken () [0x001ff] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadProperty (Gameloop.Vdf.VdfReader reader) [0x0000d] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadObject (Gameloop.Vdf.VdfReader reader) [0x00035] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadProperty (Gameloop.Vdf.VdfReader reader) [0x00058] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadObject (Gameloop.Vdf.VdfReader reader) [0x00035] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.ReadProperty (Gameloop.Vdf.VdfReader reader) [0x00058] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfSerializer.Deserialize (System.IO.TextReader textReader) [0x0003c] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfConvert.Deserialize (System.IO.TextReader reader, Gameloop.Vdf.VdfSerializerSettings settings) [0x00014] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfConvert.Deserialize (System.String value, Gameloop.Vdf.VdfSerializerSettings settings) [0x00006] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at Gameloop.Vdf.VdfConvert.Deserialize (System.String value) [0x00006] in <0d48bf6fbeb842b39220c642cedcbd03>:0 
  at vdftest.MainClass.Main (System.String[] args) [0x00023] in /home/my_username/Projects/vdftest/vdftest/Program.cs:27 
@shravan2x
Copy link
Owner

shravan2x commented Mar 2, 2022

The error appears to be thrown because the DownloadsStoreRecentlyCompleted value length exceeds the maximum token size constant. Valve's own code used this constant, but it's possible they've changed it since. I can make this adjustable in settings.

Is this a naturally occuring VDF file (i.e. created by an unmodified steam client)?

@Baguettedood
Copy link
Author

Baguettedood commented Mar 3, 2022

It is indeed an unmodified Steam client. The DownloadsStoreRecentlyCompleted section seems to change when Steam finishes downloading updates. In a very limited test I did, the section might be Linux-only. I can provide my entire config.vdf if you require it.

@shravan2x
Copy link
Owner

Thanks for clarifying. I'll push 0.6.2 this weekend with an option to adjust the maximum token size.

@shravan2x
Copy link
Owner

I've pushed 0.6.2. Could you try your code again with this line replaced?

VProperty volvo = VdfConvert.Deserialize(text, new VdfSerializerSettings() { MaximumTokenSize = 8192, UsesEscapeSequences = true });

@Baguettedood
Copy link
Author

With the update and replaced line, it seems to parse correctly, and I'm again able to retrieve values from the full config.vdf's software section. Thanks for the fix.

In case it's relevant, the DownloadsStoreRecentlyCompleted section appeared around the 1st of February according to A friend's project that dealt with the same config.vdf, though that project's issue was bad parsing of escape sequences. Not sure how long it would've taken for the section to grow beyond the official length specification, however.

@shravan2x
Copy link
Owner

Appreciate the context! I'll go ahead and close this issue now - feel free to reopen if necessary.

@AnotherPillow
Copy link

Looks like localconfig.vdf also causes this issue. Max token size of 8192 didn't work but 16384 did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants