Re: [PATCH] tests: Lower stack usage below 4096 bytes

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

 



2011/4/25 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>:
> 2011/4/25 Eric Blake <eblake@xxxxxxxxxx>:
>> On 04/24/2011 04:26 PM, Matthias Bolte wrote:
>>> Make virtTestLoadFile allocate the buffer to read the file into.
>>>
>>> Fix logic error in virtTestLoadFile, stop reading on the an empty line.
>>>
>>> Use virFileReadLimFD in virtTestCaptureProgramOutput.
>>> ---
>>> +++ b/tests/commandhelper.c
>>> @@ -99,8 +99,8 @@ int main(int argc, char **argv) {
>>> Â Â Â}
>>>
>>> Â Â Âfprintf(log, "DAEMON:%s\n", getpgrp() == getsid(0) ? "yes" : "no");
>>> - Â Âchar cwd[1024];
>>> - Â Âif (!getcwd(cwd, sizeof(cwd)))
>>> + Â Âchar *cwd = NULL;
>>> + Â Âif (!(cwd = getcwd(NULL, 0)))
>>
>> Ouch. ÂThis is not portable to POSIX, and while gnulib can guarantee
>> that it works, the current gnulib getcwd module is GPL (and relies on
>> openat, which is a rather heavy-weight replacement!).
>>
>> I'm going to work on a gnulib module getcwd-lgpl which doesn't fix all
>> the known bugs in getcwd, but at least guarantees that getcwd(NULL,0)
>> will malloc insofar as the underlying getcwd is not buggy; we'll need to
>> import that into libvirt before applying the rest of this patch.
>>
>> I haven't closely reviewed the rest of this patch yet, but like the
>> general idea once we have getcwd sorted out.
>>
>
> Oops. At first I used getcwd(NULL, 0) to replace the getcwd(cwd,
> sizeof(cwd)) calls in the main functions, but then decided to just
> move the cwd buffer to global scope instead. I just missed this one in
> the second rewrite round.
>
> Matthias
>

Grep'ing the rest of the codebase shows a getcwd(NULL, 0) call in
virFileAbsPath that probably needs care too.

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]