[netcf-devel] [PATCH 1/3] ncftool: Allow a one shot, non-interactive command
Cole Robinson
crobinso at redhat.com
Mon Feb 8 14:35:29 UTC 2010
On 02/04/2010 02:44 PM, David Lutterkort wrote:
> 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);
> }
Whoops, thanks for the fix.
- Cole
More information about the netcf-devel
mailing list