diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-09-15 13:01:10 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-09-15 13:01:10 +0100 |
commit | 2383d7a78e8abc308e36b2045087a9785c893f49 (patch) | |
tree | 919b434bcb07c99f6c815e6e03b1394a78858ff4 /src/launch-appliance.c | |
parent | a67129b0fb45b2f83eb711c6c599569d0f53e580 (diff) | |
download | libguestfs-2383d7a78e8abc308e36b2045087a9785c893f49.tar.gz libguestfs-2383d7a78e8abc308e36b2045087a9785c893f49.tar.xz libguestfs-2383d7a78e8abc308e36b2045087a9785c893f49.zip |
syntax: Remove PATH_MAX-sized buffers allocated on the stack.
On Linux PATH_MAX is 4096, but on some platforms it can be much larger
or even not defined (ie. unlimited). Therefore using a PATH_MAX-sized
stack buffer is not a great idea for portable programs.
This change removes use of PATH_MAX-sized stack-allocated buffers.
This change only applies to the library and standalone programs.
Inside the daemon, memory allocation is much more complicated so I
have not changed those (yet).
Found by 'make syntax-check'.
Diffstat (limited to 'src/launch-appliance.c')
-rw-r--r-- | src/launch-appliance.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/launch-appliance.c b/src/launch-appliance.c index d63d3140..ff3b7308 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -294,9 +294,10 @@ launch_appliance (guestfs_h *g, const char *arg) cachemode = ",cache=writeback"; } - char buf2[PATH_MAX + 64]; + size_t buf2_len = strlen (appliance) + 64; + char buf2[buf2_len]; add_cmdline (g, "-drive"); - snprintf (buf2, sizeof buf2, "file=%s,snapshot=on,id=appliance,if=%s%s", + snprintf (buf2, buf2_len, "file=%s,snapshot=on,id=appliance,if=%s%s", appliance, virtio_scsi ? "none" : "virtio", cachemode); add_cmdline (g, buf2); |