Re: [PATCH 2/3] tests: Don't pass INT_MAX to virFileReadAll()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 14, 2021 at 14:14:47 +0200, Michal Prívozník wrote:
> On 6/14/21 1:31 PM, Tim Wiederhake wrote:
> > On Mon, 2021-06-14 at 13:06 +0200, Michal Privoznik wrote:
> >> In a few occasions in tests we pass INT_MAX to
> >> virFileReadLimFD(). This is not safe because virFileReadAll()
> >> will call virFileReadLimFD() under the hood which takes the limit
> >> and adds 1 to it.
> > 
> > Calling virFileReadAll with "INT_MAX - 1" looks funny. Is it possible
> > to check for "maxlen >= INT_MAX" in virFileReadLimFD instead?
> 
> Actually, I don't understand why we need to add 1 in the first place.
> I'll push the other two patches and send v2 for this that removes the +1.

It's so that it guarantees that a file of 'maxlen' length is read
completely and the terminating '\0' is in the resulting string.

Removing the '+ 1' would change this kind of semantics, which may
require audit of all callers.




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux