Commit Graph

7 Commits

Author SHA1 Message Date
Richard W.M. Jones
d5a8f82887 Use 'const' for stack integers where possible.
May improve optimization possibilities in a few cases.
2016-07-26 10:43:45 +01:00
Richard W.M. Jones
07c496c53c Use less stack.
GCC has two warnings related to large stack frames.  We were already
using the -Wframe-larger-than warning, but this reduces the threshold
from 10000 to 5000 bytes.

However that warning only covers the static part of frames (not
alloca).  So this change also enables -Wstack-usage=10000 which covers
both the static and dynamic usage (alloca and variable length arrays).

Multiple changes are made throughout the code to reduce frames to fit
within these new limits.

Note that stack allocation of large strings can be a security issue.
For example, we had code like:

 size_t len = strlen (fs->windows_systemroot) + 64;
 char software[len];
 snprintf (software, len, "%s/system32/config/software",
           fs->windows_systemroot);

where fs->windows_systemroot is guest controlled.  It's not clear what
the effects might be of allowing the guest to allocate potentially
very large stack frames, but at best it allows the guest to cause
libguestfs to segfault.  It turns out we are very lucky that
fs->windows_systemroot cannot be set arbitrarily large (see checks in
is_systemroot).

This commit changes those to large heap allocations instead.
2016-03-07 17:36:24 +00:00
Richard W.M. Jones
d60e6a23a6 examples: Update various examples to use new disk-create API. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
c74f7f15cb examples: If user does 'mount-local --help' don't create a disk image called '--help'. 2013-05-20 21:46:49 +01:00
Richard W.M. Jones
2da8d49590 examples: Don't ignore return value of chdir.
GCC 4.7.3 whinges about this.
2013-04-19 15:29:50 +01:00
Richard W.M. Jones
1399005d7e examples: Ensure each example program is documented. 2013-02-12 16:31:10 +00:00
Richard W.M. Jones
e84d6e6102 examples: Rename example programs, replacing '_' with '-'. 2013-02-12 16:31:10 +00:00