[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeaddons/kfile-plugins/html
From:       Luciano Montanaro <mikelima () virgilio ! it>
Date:       2004-03-19 10:31:55
Message-ID: 20040319103155.1D65F997F () office ! kde ! org
[Download RAW message or body]

CVS commit by montanaro: 

Fix crash on overly large files.


  M +7 -4      kfile_html.cpp   1.7


--- kdeaddons/kfile-plugins/html/kfile_html.cpp  #1.6:1.7
@@ -64,7 +64,10 @@ 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