You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing a compressed file with Godot and then intentionally modifying it using a hex editor, the file can still be opened by Godot and does not return an error in GDscript (file.open_compressed(OUTPUT_FILE, File.READ, COMPRESSION) returns OK). It still prints an error though (can't be detected AFAIK in GDscript). When the corupted part of the file is farer away from the beginning of the file (i presume because it does not fit into the intial buffer), the error is printed as well when calling one of the get_* methods. But get_error() is always OK.
Shouldn't this return ERR_FILE_CORRUPT when decompress() returns -1 so that the user knows the file is corrupt?
Steps to reproduce
Write a compressed file (compression method does not matter i think) using Godot
varfile:=File.new()
varres:=file.open_compressed(OUTPUT_FILE, File.WRITE, File.COMPRESSION_GZIP)
ifres!=OK:
printerr("Failed to open file for writing")
returnfile.store_string("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
file.close()
print("File written!")
Open the file in a Hex Editor and change something (not the magic number at the start)
Read the file using Godot again
varfile:=File.new()
varres:=file.open_compressed(OUTPUT_FILE, File.READ, File.COMPRESSION_GZIP)
ifres!=OK:
printerr("Failed to open file for reading")
returnprint(file.get_error())
file.get_buffer(file.get_len())
print(file.get_error())
file.close()
file.get_error() and file.open_compressed() will not report errors. But you can see some errors in the Debugger.
Godot version
3.4.2
System information
Windows 11
Issue description
When writing a compressed file with Godot and then intentionally modifying it using a hex editor, the file can still be opened by Godot and does not return an error in GDscript (
file.open_compressed(OUTPUT_FILE, File.READ, COMPRESSION)
returnsOK
). It still prints an error though (can't be detected AFAIK in GDscript). When the corupted part of the file is farer away from the beginning of the file (i presume because it does not fit into the intial buffer), the error is printed as well when calling one of theget_*
methods. Butget_error()
is alwaysOK
.This is the error:
The return value of decompress method is dicarded in all instances when it is called in
file_access_compressed.cpp
. For example:godot/core/io/file_access_compressed.cpp
Lines 272 to 278 in 45eaa2d
Shouldn't this return
ERR_FILE_CORRUPT
whendecompress()
returns -1 so that the user knows the file is corrupt?Steps to reproduce
file.get_error()
andfile.open_compressed()
will not report errors. But you can see some errors in the Debugger.Minimal reproduction project
FileCompressionBug.zip
The text was updated successfully, but these errors were encountered: