[kde-solaris] Fix for save dialog crashes when long file names
Aaron Williams
aaron_williams at net.com
Sat Nov 6 06:43:55 CET 2004
I was experiencing crashes whenever I attempted to save a file in a
directory that contains a long filename. Debugging the problem was
tricky since the bug causes stack corruption. The bug shows up on
Solaris, and probably IRIX and other platforms too.
See http://bugs.kde.org/show_bug.cgi?id=90004
Hopefully someone with CVS access can apply my patch (or come up with
a better one).
Apply to kdelibs-3.3.1/kio/kio/kurlcompletion.cpp:
diff -u kurlcompletion.cpp.old kurlcompletion.cpp
--- kurlcompletion.cpp.old 2004-06-22 10:36:41.000000000 -0700
+++ kurlcompletion.cpp 2004-11-05 21:33:53.869998000 -0800
@ -219,10 +219,22 @
// Loop through all directory entries
- struct dirent dirPosition;
+ struct dirent *dirPosition;
struct dirent *dirEntry = 0;
+ // Note that we need to allocate extra storage space
for
+ // dirPosition according to the IRIX man page. This
also
+ // fits for Solaris, where failure to do this causes
heap
+ // and/or stack corruption.
+
+ // Get maximum file name size for this directory
+ int max_name_length =
pathconf( QFile::encodeName( *it ),
+ _PC_NAME_MAX);
+ // Allocate position storage
+ dirPosition = (struct dirent *)malloc(sizeof(dirent)
+
+ max_name_length
+ 1);
while ( !terminationRequested() &&
- ::readdir_r( dir, &dirPosition, &dirEntry ) ==
0 && dirEntry )
+ ::readdir_r( dir, dirPosition, &dirEntry ) ==
0 &&
+ dirEntry )
{
// Skip hidden files if m_noHidden is true
@ -280,6 +292,9 @
::closedir( dir );
dir = 0;
+
+ free(dirPosition);
+ dirPosition = 0;
}
done();
;
More information about the kde-solaris
mailing list