netcf-devel  

Re: [netcf-devel] [PATCH 1/3] ncftool: Allow a one shot, non-interactive command

David Lutterkort
Thu, 04 Feb 2010 11:44:52 -0800

On Sat, 2010-01-30 at 19:59 -0500, Cole Robinson wrote:
> Similar to how virsh works, one shot commands can be invoked as:
> 
> ncftool <cmd> <options>

ACK. The use of malloc wasn't right, since you did strncat into a
malloc'd area that was never zeroed. I changed that with this
incremental patch:

diff --git a/src/ncftool.c b/src/ncftool.c
index 96276e9..35e9252 100644
--- a/src/ncftool.c
+++ b/src/ncftool.c
@@ -803,8 +803,8 @@ int main(int argc, char **argv) {
             cmdsize += strlen(argv[i]) + 1;
         }
 
-        cmd = malloc(cmdsize + 1);
-        if (!cmd) {
+        r = ALLOC_N(cmd, cmdsize + 1);
+        if (r < 0) {
             fprintf(stderr, "Out of memory\n");
             exit(EXIT_FAILURE);
         }



_______________________________________________
netcf-devel mailing list
netcf-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/netcf-devel