On Mon, Sep 17, 2012 at 10:23:04AM +0200, Jim Meyering wrote:
>> prohibit_path_max_allocation
>> daemon/initrd.c:41: char filename[PATH_MAX];
>> daemon/initrd.c:126: char fullpath[PATH_MAX];
>> daemon/inotify.c:310: char buf[PATH_MAX];
>> daemon/link.c:38: char link[PATH_MAX];
>> daemon/link.c:63: char link[PATH_MAX];
>> daemon/realpath.c:86: char ret[PATH_MAX+1] = "/";
>> daemon/xattr.c:272: char pathname[PATH_MAX];
>> src/launch-appliance.c:179: addr.sun_path[UNIX_PATH_MAX-1] = '\0';
>> src/launch-libvirt.c:200: addr.sun_path[UNIX_PATH_MAX-1] = '\0';
>> src/launch-libvirt.c:224: addr.sun_path[UNIX_PATH_MAX-1] = '\0';
>> src/launch-unix.c:64: addr.sun_path[UNIX_PATH_MAX-1] = '\0';
>> maint.mk: Avoid stack allocations of size PATH_MAX
>> make: *** [sc_prohibit_path_max_allocation] Error 1
>
> The daemon ones are bugs in libguestfs. I haven't fixed them yet.
>
> However the use of UNIX_PATH_MAX looks OK to me. I think the regexp
> is over-matching.
Good catch.
The regexp in that test is too loose. This fixes it:
diff --git a/top/maint.mk b/top/maint.mk
index 4627bc5..a6d1324 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -1216,7 +1216,7 @@ sc_Wundef_boolean:
# not be constant, or might overflow a stack. In general, use PATH_MAX as
# a limit, not an array or alloca size.
sc_prohibit_path_max_allocation:
- @prohibit='(\balloca *\([^)]*|\[[^]]*)PATH_MAX' \
+ @prohibit='(\balloca *\([^)]*|\[[^]]*)\bPATH_MAX' \
halt='Avoid stack allocations of size PATH_MAX' \
$(_sc_search_regexp)
Tested and confirmed this patch works.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org