summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-30 13:35:36 +0100
committerRichard Jones <rjones@redhat.com>2009-04-30 13:35:36 +0100
commit6dff51fc7d8a33925f164bd66c2c26cd4b94b3df (patch)
treea3fdebfd9b270c9f205255da7c27949e22c7b9dd /daemon
parent668d27b56857230fb81c04d1663a5aca1b9e77b9 (diff)
downloadlibguestfs-6dff51fc7d8a33925f164bd66c2c26cd4b94b3df.tar.gz
libguestfs-6dff51fc7d8a33925f164bd66c2c26cd4b94b3df.tar.xz
libguestfs-6dff51fc7d8a33925f164bd66c2c26cd4b94b3df.zip
Check return value from realloc call (Jim Meyering).
Diffstat (limited to 'daemon')
-rw-r--r--daemon/stubs.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/daemon/stubs.c b/daemon/stubs.c
index cafadbea..019e4fb2 100644
--- a/daemon/stubs.c
+++ b/daemon/stubs.c
@@ -940,9 +940,14 @@ static void vgcreate_stub (XDR *xdr_in)
return;
}
volgroup = args.volgroup;
- args.physvols.physvols_val = realloc (args.physvols.physvols_val, sizeof (char *) * (args.physvols.physvols_len+1));
- args.physvols.physvols_val[args.physvols.physvols_len] = NULL;
- physvols = args.physvols.physvols_val;
+ physvols = realloc (args.physvols.physvols_val,
+ sizeof (char *) * (args.physvols.physvols_len+1));
+ if (physvols == NULL) {
+ reply_with_perror ("realloc");
+ goto done;
+ }
+ physvols[args.physvols.physvols_len] = NULL;
+ args.physvols.physvols_val = physvols;
r = do_vgcreate (volgroup, physvols);
if (r == -1)
@@ -1028,9 +1033,14 @@ static void sfdisk_stub (XDR *xdr_in)
cyls = args.cyls;
heads = args.heads;
sectors = args.sectors;
- args.lines.lines_val = realloc (args.lines.lines_val, sizeof (char *) * (args.lines.lines_len+1));
- args.lines.lines_val[args.lines.lines_len] = NULL;
- lines = args.lines.lines_val;
+ lines = realloc (args.lines.lines_val,
+ sizeof (char *) * (args.lines.lines_len+1));
+ if (lines == NULL) {
+ reply_with_perror ("realloc");
+ goto done;
+ }
+ lines[args.lines.lines_len] = NULL;
+ args.lines.lines_val = lines;
r = do_sfdisk (device, cyls, heads, sectors, lines);
if (r == -1)
@@ -1176,9 +1186,14 @@ static void command_stub (XDR *xdr_in)
reply_with_error ("%s: daemon failed to decode procedure arguments", "command");
return;
}
- args.arguments.arguments_val = realloc (args.arguments.arguments_val, sizeof (char *) * (args.arguments.arguments_len+1));
- args.arguments.arguments_val[args.arguments.arguments_len] = NULL;
- arguments = args.arguments.arguments_val;
+ arguments = realloc (args.arguments.arguments_val,
+ sizeof (char *) * (args.arguments.arguments_len+1));
+ if (arguments == NULL) {
+ reply_with_perror ("realloc");
+ goto done;
+ }
+ arguments[args.arguments.arguments_len] = NULL;
+ args.arguments.arguments_val = arguments;
r = do_command (arguments);
if (r == NULL)
@@ -1205,9 +1220,14 @@ static void command_lines_stub (XDR *xdr_in)
reply_with_error ("%s: daemon failed to decode procedure arguments", "command_lines");
return;
}
- args.arguments.arguments_val = realloc (args.arguments.arguments_val, sizeof (char *) * (args.arguments.arguments_len+1));
- args.arguments.arguments_val[args.arguments.arguments_len] = NULL;
- arguments = args.arguments.arguments_val;
+ arguments = realloc (args.arguments.arguments_val,
+ sizeof (char *) * (args.arguments.arguments_len+1));
+ if (arguments == NULL) {
+ reply_with_perror ("realloc");
+ goto done;
+ }
+ arguments[args.arguments.arguments_len] = NULL;
+ args.arguments.arguments_val = arguments;
r = do_command_lines (arguments);
if (r == NULL)
@@ -1855,9 +1875,14 @@ static void debug_stub (XDR *xdr_in)
return;
}
subcmd = args.subcmd;
- args.extraargs.extraargs_val = realloc (args.extraargs.extraargs_val, sizeof (char *) * (args.extraargs.extraargs_len+1));
- args.extraargs.extraargs_val[args.extraargs.extraargs_len] = NULL;
- extraargs = args.extraargs.extraargs_val;
+ extraargs = realloc (args.extraargs.extraargs_val,
+ sizeof (char *) * (args.extraargs.extraargs_len+1));
+ if (extraargs == NULL) {
+ reply_with_perror ("realloc");
+ goto done;
+ }
+ extraargs[args.extraargs.extraargs_len] = NULL;
+ args.extraargs.extraargs_val = extraargs;
r = do_debug (subcmd, extraargs);
if (r == NULL)