JesusFreke / smali

smali/baksmali
6.3k stars 1.07k forks source link

Change MAX_FILENAME_LENGTH to 180 #845

Open crackleeeessyp opened 2 years ago

crackleeeessyp commented 2 years ago

On windows, if we put the apk/dex file on desktop or other path such as C:\Users\xxxxxx\Desktop\folder\test.apk. Some dex may produce long file path smali file which cannot handled by Windows application, so shorten the MAX_FILENAME_LENGTH to 180 to make sure that it works in most cases.

Related issue: https://github.com/iBotPeaches/Apktool/issues/1582 https://github.com/JesusFreke/smali/issues/541

ale5000-git commented 1 year ago

Why? Isn't better to add support for longer filenames? Windows can support path with length of 32767 characters.

S4muii commented 1 year ago

I had a similar issue with it on Linux and an encrypted partition . the maximum allowed filename length there is ~140 cause here and my issue was with an androidx class . so I think it might be here to stay the name of the class was "androidx/recyclerview/widget/RecyclerView$MediaControllerCompat$MediaControllerImplApi21$ExtraBinderRequestResultReceiver$MediaBrowserCompat$CustomActionResultReceiver.smali" it got written normally on a NTFS unencrypted partition but not on the ext4 encrypted one. we need a way to make a universal patch . like trying to write files to the path with long filenames until we figure out the limit instead of hardcoding a value maybe ?

crackleeeessyp commented 1 year ago

That's right for windows can support path with length of 32767 characters, however, some program languages/ and old windows may not support 32767 but only 256, and would introduce problem when handle these long path files.

Current implementation uses 256 as max file length, however, it doesn't consider that current folder path may contain several characters.

I think @samuii1 is right, maybe we need find a way to make sure that long name not exceeded to 256 characters include current folder path character.