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

List:       kde-utils-devel
Subject:    Review Request: fix 4 TB wrap-around of filelight reported sizes on
From:       "Anssi Hannula" <anssi () mageia ! org>
Date:       2011-10-15 16:19:26
Message-ID: 20111015161926.11765.26779 () vidsolbach ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102870/
-----------------------------------------------------------

Review request for KDE Utils.


Description
-------

Filelight internally uses a FileSize type in fileTree.h to represent
file sizes. It is defined as unsigned long and contains kilobytes,
therefore it will wrap around at 4 TB when long int is 32-bit, while
64-bit is safe.

However, File::humanReadableSize() takes the size as uint instead of
FileSize, causing it wrap-around even if long int would be big enough.
This causes e.g. directories that take up 6 TB to have a caption
saying 2 TB usage (the graph is generated correctly, though).

Change it to use FileSize to avoid wrap-around on 64-bit systems where
long int is 64-bit, and to make it consistent with other code.

32-bit systems continue to be affected.

This could be trivially fixed on 32-bit systems as well after this patch by=
 making FileSize always a 64-bit integer (and maybe dropping the divide-by-=
1024 trick), but since 32-bit int seems to be used due to performance reaso=
ns and I couldn't test it on a real 32-bit system, I'll leave that to someo=
ne else who can test it or knows for sure that the performance impact would=
 be less than the impact of the wrap-around bug.


Diffs
-----

  src/part/fileTree.h fe0a9ec =

  src/part/fileTree.cpp 6da7a8f =


Diff: http://git.reviewboard.kde.org/r/102870/diff/diff


Testing
-------

Built filelight in kdeutils-4.6.5 with this change and wrap-around was fixe=
d. Code in git master seems to have no actual code changes since then.


Thanks,

Anssi Hannula


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/102870/">http://git.reviewboard.kde.org/r/102870/</a>
  </td>
    </tr>
   </table>
   <br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black solid;">  <tr>
  <td>

<div>Review request for KDE Utils.</div>
<div>By Anssi Hannula.</div>







<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px \
solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Filelight internally \
uses a FileSize type in fileTree.h to represent file sizes. It is defined as unsigned long and \
contains kilobytes, therefore it will wrap around at 4 TB when long int is 32-bit, while
64-bit is safe.

However, File::humanReadableSize() takes the size as uint instead of
FileSize, causing it wrap-around even if long int would be big enough.
This causes e.g. directories that take up 6 TB to have a caption
saying 2 TB usage (the graph is generated correctly, though).

Change it to use FileSize to avoid wrap-around on 64-bit systems where
long int is 64-bit, and to make it consistent with other code.

32-bit systems continue to be affected.

This could be trivially fixed on 32-bit systems as well after this patch by making FileSize \
always a 64-bit integer (and maybe dropping the divide-by-1024 trick), but since 32-bit int \
seems to be used due to performance reasons and I couldn&#39;t test it on a real 32-bit system, \
I&#39;ll leave that to someone else who can test it or knows for sure that the performance \
impact would be less than the impact of the wrap-around bug. </pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid \
#b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; \
white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Built filelight in \
kdeutils-4.6.5 with this change and wrap-around was fixed. Code in git master seems to have no \
actual code changes since then.</pre>  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>src/part/fileTree.h <span style="color: grey">(fe0a9ec)</span></li>

 <li>src/part/fileTree.cpp <span style="color: grey">(6da7a8f)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/102870/diff/" style="margin-left: 3em;">View \
Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>



_______________________________________________
Kde-utils-devel mailing list
Kde-utils-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-utils-devel


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

Configure | About | News | Add a list | Sponsored by KoreLogic