AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unhandled Win32 exception AkelPad.exe 13132 - long filenames

 
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (English)
View previous topic :: View next topic  
Author Message
CBruce



Joined: 15 Oct 2015
Posts: 20

PostPosted: Fri Mar 16, 2018 4:46 am    Post subject: Unhandled Win32 exception AkelPad.exe 13132 - long filenames Reply with quote

I have some files with LONG filenames that look like they might be causing AkelPad to throw an exception error.

Individual filenames up to 218 characters long.
Path + filename up to 244 characters long.

If I move a file to the root folder and try to open/save it, AkelPad still crashes.

Both the filename length and the path+filename length are well within the Windows limits - and I don't have problems with any other applications that are dealing with them - (file explorer, internet browsers, etc.).

I can't find the filename buffer in the AkelPad source code - so I'm wondering if anyone knows what AkelPad has for a maximum filename length?

Thanks,
CBruce
Back to top
View user's profile Send private message
DV



Joined: 16 Nov 2006
Posts: 1015
Location: Kyiv, Ukraine

PostPosted: Fri Mar 16, 2018 1:35 pm    Post subject: Re: Unhandled Win32 exception AkelPad.exe 13132 - long filen Reply with quote

I think I know what is happening.
All the file name buffers in AkelPad's source code are declared as
Code:
wchar_t wszOpenFile[MAX_PATH];

Code:
wchar_t wszFile[MAX_PATH];

and so on.
Correspondingly, if the full path name to be opened is exactly MAX_PATH characters long, there is no space for the last trailing '\0' character in the wszOpenFile/wszFile/etc buffer and it leads either to overflow that can be survived or to overflow that can not. (The exact behavior seems to rely on the current memory state of the application.)
Most likely automatic replacements of all
Code:
[MAX_PATH]

to
Code:
[MAX_PATH+1]

should fix the problem (don't omit the square brackets!).
Back to top
View user's profile Send private message
DV



Joined: 16 Nov 2006
Posts: 1015
Location: Kyiv, Ukraine

PostPosted: Fri Mar 16, 2018 2:17 pm    Post subject: Re: Unhandled Win32 exception AkelPad.exe 13132 - long filen Reply with quote

Or maybe I'm wrong.
As far as I can see, the file path becomes corrupted after calling the system's function GetFullPathNameW from the function GetFullPathNameWide.
Interestingly, GetFullPathNameW can return 261 (MAX_PATH+1) even when the buffer length passed to it was 260 (MAX_PATH) - and in this case GetFullPathNameW does not fill its second string parameter completely, leaving garbage in it.
Back to top
View user's profile Send private message
CBruce



Joined: 15 Oct 2015
Posts: 20

PostPosted: Fri Mar 16, 2018 3:21 pm    Post subject: Reply with quote

My immediate thought was that the path+filename was too long for MAX_PATH - but remember, I said that my max path in use is only 244 characters.

So I had time to play a bit this morning and found out that AkelPad abends when the path+filename >= 197.

Perhaps AkelPad is internally quoting the filename (+2 characters) and allowing for a null byte (+1 character) and only has a buffer length of 200 characters?... Because 197 seems a bit odd.

Anyway, that 197/200 length is 60 characters shorter than Windows MAX_PATH.

I'm on Windows 10 Pro 64-bit English.
Back to top
View user's profile Send private message
DV



Joined: 16 Nov 2006
Posts: 1015
Location: Kyiv, Ukraine

PostPosted: Sat Mar 17, 2018 5:30 pm    Post subject: Reply with quote

Please provide an example of path + file name < 200 characters that leads to a problem. Or better two examples. I could not reproduce it with full path length less than 260, though it's under Windows 7 64-bit.
Oh, and AkelPad itself is 32-bit or 64-bit?
Back to top
View user's profile Send private message
CBruce



Joined: 15 Oct 2015
Posts: 20

PostPosted: Sat Mar 17, 2018 7:54 pm    Post subject: Reply with quote

The abend occurs when I edit and then hit Ctrl-S to save the file.

It can be the only file being edited - or one of many files.

Mistake above: >= 198 not 197... which leads me back to a 200 byte/character buffer which would allow for a quoted path string.

EDIT: hmm... testing some more... sometimes it's a length of 198, sometimes 199, sometimes 200 that causes the abend.

AkelPad 4.9.8 x64

(97 KB file) - (path length = 210)
--------------------------------------
D:\BEH_Projects\Project 001\BEH(12) - Bit Twiddling Hacks - Sean Anderson - (indistinguishability obfuscation, public key, PKE, subleq, brainfuck, bits, bit operations, metamorph, polymorphic, encryption,).html

(2 KB file) - (path length = 198)
(this was my test path name to figure out where the break was)
------------------------------------
D:\BEH_Projects\Project 001\BEH(12) - Some Bit Twiddling functions explained - Project Nayuki - (indistinguishability obfuscation, source code, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234567.txt
Back to top
View user's profile Send private message
DV



Joined: 16 Nov 2006
Posts: 1015
Location: Kyiv, Ukraine

PostPosted: Tue Mar 20, 2018 10:28 am    Post subject: Reply with quote

I could not reproduce it under Windows 7 64-bit.
It might be something related to particular environment (Windows 10? disk encryption? antivirus? etc?). What about other editors: the standard Notepad, SciTE, Notepad++, etc. - are you sure they don't have the same problem?
Back to top
View user's profile Send private message
opk44



Joined: 16 Jan 2010
Posts: 607

PostPosted: Tue Mar 20, 2018 10:58 am    Post subject: Reply with quote

1. I could not reproduce it too (under Windows XP 32-bit).
2. Maybe SaveFile plugin is "ON" (with SaveMethod = "Save a copy in directory")?
Back to top
View user's profile Send private message
CBruce



Joined: 15 Oct 2015
Posts: 20

PostPosted: Tue Mar 20, 2018 6:59 pm    Post subject: SOLVED !!! Reply with quote

Great catch, opk44 !!!

It was:
2. Maybe SaveFile plugin is "ON" (with SaveMethod = "Save a copy in directory")?

No problems at all with the [Save Copy] option turned off.

I use PortableApps version and save the copies to a directory at the head of the PortableApps directory... with that long path, and the AkelPad TMP suffix, the full path+filename of the TMP file becomes this:

D:\PortableApps\PortableApps\AkelPadPortable\App\AkelPadx64\..\..\..\..\AkelPad_temp_files\BEH1234 - Some Bit Twiddling functions explained - Project Nayuki - pindistinguishability obfuscation, source code, aaaaaaaaaaaaaaaaaaaaaaaaaaa123456789.txt.124357008.tmp

Which means that my filename itself can only be approximately 196 characters long.

Also, I think something got re-addressed in memory today... instead of [Save Copy] crashing AkelPad, I am only getting [Cannot create file "".] errors when the attempted save happens.

I'll create a MUCH shorter TMP file path to get the functionality I want.

THANKS for helping!
CBruce
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 6250

PostPosted: Fri Mar 30, 2018 6:05 pm    Post subject: Reply with quote

CBruce
SaveFile plugin v3.8
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (English) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group