[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] Fix problems in txt, html kfile-plugins
From: Luciano Montanaro <mikelima () virgilio ! it>
Date: 2004-03-17 14:40:52
Message-ID: 200403171540.52360.mikelima () virgilio ! it
[Download RAW message or body]
The kfile_txt.cpp.patch fixes bug #77006,
the second one fixes a crash obtaining creating a 0-filled 3GB file
and renaming it to pippo.html.
Opening the properties dialog for such a file crashes konqueror.
Besides, the plugin could use way too much memory just to find if
the page uses javascript. The new limit is set to 32K.
Can I apply them to CVS HEAD?
Luciano
["kfile_txt.cpp.patch" (text/x-diff)]
? kfile_txt.cpp.patch
Index: kfile_txt.cpp
===================================================================
RCS file: /home/kde/kdeaddons/kfile-plugins/txt/kfile_txt.cpp,v
retrieving revision 1.6
diff -p -u -r1.6 kfile_txt.cpp
--- kfile_txt.cpp 26 Jul 2003 20:04:46 -0000 1.6
+++ kfile_txt.cpp 17 Mar 2004 14:03:56 -0000
@@ -50,7 +50,7 @@ void KTxtPlugin::makeMimeTypeInfo(const
setAttributes(item, KFileMimeTypeInfo::Averaged);
item = addItemInfo(group, "Words", i18n("Words"), QVariant::Int);
setAttributes(item, KFileMimeTypeInfo::Averaged);
- item = addItemInfo(group, "Characters", i18n("Characters"), QVariant::Int);
+ item = addItemInfo(group, "Characters", i18n("Characters"), QVariant::ULongLong);
setAttributes(item, KFileMimeTypeInfo::Averaged);
item = addItemInfo(group, "Format", i18n("Format"), QVariant::String);
}
@@ -64,12 +64,12 @@ bool KTxtPlugin::readInfo(KFileMetaInfo&
bool firstline = true;
int totLines = 0;
int totWords = 0;
- int totChars = f.size();
+ unsigned long long totChars = f.size();
QString fileFormat;
QString line;
bool skipTotals = (totChars > 100*1024); // 100K is the max we read
- int bytesRead = 0;
+ unsigned int bytesRead = 0;
while (!f.atEnd())
{
f.readLine(line, 4096);
["kfile_html.patch" (text/x-diff)]
Index: kfile_html.cpp
===================================================================
RCS file: /home/kde/kdeaddons/kfile-plugins/html/kfile_html.cpp,v
retrieving revision 1.6
diff -p -u -r1.6 kfile_html.cpp
--- kfile_html.cpp 26 Jul 2003 20:04:46 -0000 1.6
+++ kfile_html.cpp 17 Mar 2004 14:35:39 -0000
@@ -63,9 +63,12 @@ bool KHtmlPlugin::readInfo( KFileMetaInf
// we're only interested in the header, so just read until before </head>
// or until <body> if the author forgot it
- QByteArray data(f.size()+1);
- f.readBlock(data.data(), f.size());
- data[f.size()]='\0';
+ // In this case, it's better to limit the size of the buffer to something
+ // sensible. Think a 0-filled 3GB file with an .html extension.
+ int maxBufSize = QMIN(f.size(), 32768);
+ QByteArray data(maxBufSize + 1);
+ f.readBlock(data.data(), maxBufSize);
+ data[maxBufSize]='\0';
QString s(data.data());
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic