Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Issue with writing out AES encrypted file with SaveStringToFile()

In our project we use FAES encryption/decryption to save out user information to a local file tagged with .ejs. Every once in a while, if the file becomes a sufficient size, the SaveStringToFile function will not serialize the String properly and thus on reading back from the file, the contents are not read properly. The particular issue I have found is in the following line.

 else if (SaveAsUnicode)
     Ar->Serialize( &BOM, sizeof(UCS2CHAR) );

     auto Src = StringCast<UCS2CHAR>(StrPtr, String.Len());
     Ar->Serialize( (UCS2CHAR*)Src.Get(), Src.Length() * sizeof(UCS2CHAR) );

The second variable is passed into the Serialize function as a much smaller value than is should be and causes the encrypted String to not write to the file properly.

Product Version: UE 4.19
more ▼

asked Nov 06 '18 at 10:15 PM in C++ Programming

avatar image

13 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

My first concern would be whether your encryption process could be generated a null terminator. The string then thinks that is the end of the string, even though you have arbitrarily more data that is supposed to be stored.

more ▼

answered Nov 07 '18 at 08:50 PM

Brian Johnstone (suspended)
avatar image Carrac16 Nov 08 '18 at 06:31 PM

Would that affect the length of the Src variable that's being passed into the Serializer? I didn't think the null terminator would alter the physical size of the string.

avatar image Brian Johnstone Nov 08 '18 at 09:31 PM

Sorry I was under the impression the error was happening when the encrypted string is being ready back in. You can verify that the string being saved out is not being fully saved?

avatar image Carrac16 Nov 08 '18 at 10:07 PM

I can. Before calling the StringtoFile function the string is the correct size, but somewhere between casting and passing into Serialize it loses about 100KB of data.

avatar image Brian Johnstone Nov 09 '18 at 02:50 AM

Are you able to step into the StringCast and Serialize calls? You may need to build with DebugEditor configuration but that should allow you step through the engine code and maybe you can catch when the error occurs. I'd need a reproduction project with your code and data to test here to catch it myself.

avatar image Carrac16 Nov 09 '18 at 10:21 PM

After setting up the DebugEditor config I was not able to step into the StringCast function. The only real information I was able to ascertain is that the String being cast has a size of 247969. On the instances it does not break, the Serialize function reads a passed length of 343296 or so and on the instances it fails it reads a passed length of 247904. To me it seems to be an issue happening during casting but I was unable to get under the hood of that function.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question