Re: [PATCH v3 04/11] Helper functions for host TPM support

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

 



On Tue, Apr 02, 2013 at 06:23:55AM -0400, Stefan Berger wrote:
> On 04/01/2013 04:07 PM, Corey Bryant wrote:
> >
> >
> >On 03/21/2013 11:42 AM, Stefan Berger wrote:
> >>Signed-off-by: Stefan Berger<stefanb@xxxxxxxxxxxxxxxxxx>
> >>
> >>+
> >>+char *
> >>+virTPMFindCancelPath(void)
> >>+{
> >>+    unsigned int idx;
> >>+    int len;
> >>+    DIR *pnp_dir;
> >>+    char path[100], *p;
> >
> >Is there any reason not to use PATH_MAX instead of 100 here?
> 
> You get a compiler error then due to the function using too much
> space on the stack.

The answer to that is *NOT* to use a shorter 100 byte buffer,
but to use  virAsprintf() instead of snprintf(). Never use
fixed length buffers for filepaths.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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