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

Reply via email to