D13898: Use non deprecated fastInsert in file.cpp (first of many to come)

Stefan BrĂ¼ns noreply at phabricator.kde.org
Fri Jul 6 10:56:42 BST 2018


bruns added inline comments.

INLINE COMMENTS

> jtamate wrote in file.cpp:864
> According to the man page (2+3), readlink() //does not append a null byte to buf//.
> 
>   It will (silently) truncate the contents (to a length of bufsiz characters), in case the buffer is too small to hold all of the contents.

The comment does not solve the issue, neither does it help to clarify anything ...

`buffersize` has to be larger than buff.st_size, otherwise there is no possibility to diffentiate the 'fits exactly' and 'was truncated' cases, both will return `n == buffersize`.

the correct fix is to use:

  // Add one to the size, to be able to detect truncation -
  // in case n == bufferSize, truncation *may* have occured
  size_t bufferSize = qBound(lowerLimit, buff.st_size + 1, 1024);

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D13898

To: jtamate, dfaure, #frameworks
Cc: bruns, kde-frameworks-devel, michaelh, ngraham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180706/f3fd6548/attachment.html>


More information about the Kde-frameworks-devel mailing list