This is for (JCIFS, JCIFSNG, or SMBJ)ProxyFileCallbackSafe. The none safe onRead() functions return 0 bytes read at EOF. But I noticed SMBJ and JCIFS-NG (safe onRead()) return -1 to indicate EOF.
This causes lots of problems. The app trying to read a file might not expect to see -1 (wrapped to 4GB if 32bit) to be read and complains that the file size is not expected and too big.
Without this fix, an exception would have been thrown, a very long exception with stack trace error log. CIFS Document Provider completely crashes, and then afterwards, the notification of "Opening file" shows up and there is no file opened. I had to force close CIFS Document Provider then.
I am not sure about JCIFS (SMBv1), since my TrueNAS server doesn't support SMBv1, I can't test it. But I assume it would be the same, since JAVA usually returns -1 for end of file. I tested SMBJ and JCIFS-NG, which both had the same issue.
The program I used for testing, AetherSX2 loading BIOS file either SCPH10000.bin or SCPH39001.bin would trigger the issue. Which only happens on Safe transfers enabled. Below are screenshots of the logcat before and after.
The solution might not be optimal, feel free to modify as you like.
This is for (JCIFS, JCIFSNG, or SMBJ)ProxyFileCallbackSafe. The none safe
onRead()
functions return 0 bytes read at EOF. But I noticed SMBJ and JCIFS-NG (safeonRead()
) return -1 to indicate EOF.This causes lots of problems. The app trying to read a file might not expect to see -1 (wrapped to 4GB if 32bit) to be read and complains that the file size is not expected and too big.
Without this fix, an exception would have been thrown, a very long exception with stack trace error log. CIFS Document Provider completely crashes, and then afterwards, the notification of
"Opening file"
shows up and there is no file opened. I had to force close CIFS Document Provider then.I am not sure about JCIFS (SMBv1), since my TrueNAS server doesn't support SMBv1, I can't test it. But I assume it would be the same, since JAVA usually returns -1 for end of file. I tested SMBJ and JCIFS-NG, which both had the same issue.
The program I used for testing, AetherSX2 loading BIOS file either
SCPH10000.bin
orSCPH39001.bin
would trigger the issue. Which only happens on Safe transfers enabled. Below are screenshots of the logcat before and after.The solution might not be optimal, feel free to modify as you like.