summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-07 10:42:15 +0100
committerRichard Jones <rjones@redhat.com>2009-04-07 10:42:15 +0100
commitaf92796e0308b31c9a6167e1c7bde6510ca409d7 (patch)
tree1c6edd4b4f8c25505abd8f0a09cfaf1e85045026 /src
parent6085137e65cb63aaf725207f2929a571d1149420 (diff)
downloadlibguestfs-af92796e0308b31c9a6167e1c7bde6510ca409d7.tar.gz
libguestfs-af92796e0308b31c9a6167e1c7bde6510ca409d7.tar.xz
libguestfs-af92796e0308b31c9a6167e1c7bde6510ca409d7.zip
Fix incorrect realloc size which was causing 'ls' command to fail on large directories.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/generator.ml5
-rw-r--r--src/guestfs-actions.c18
2 files changed, 16 insertions, 7 deletions
diff --git a/src/generator.ml b/src/generator.ml
index d5989754..5aaea82e 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -733,7 +733,10 @@ and generate_client_actions () =
pr " return rv.ret.%s; /* caller will free */\n" n
| RStringList n ->
pr " /* caller will free this, but we need to add a NULL entry */\n";
- pr " rv.ret.%s.%s_val = safe_realloc (g, rv.ret.%s.%s_val, rv.ret.%s.%s_len + 1);\n" n n n n n n;
+ pr " rv.ret.%s.%s_val =" n n;
+ pr " safe_realloc (g, rv.ret.%s.%s_val,\n" n n;
+ pr " sizeof (char *) * (rv.ret.%s.%s_len + 1));\n"
+ n n;
pr " rv.ret.%s.%s_val[rv.ret.%s.%s_len] = NULL;\n" n n n n;
pr " return rv.ret.%s.%s_val;\n" n n
| RPVList n ->
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
index 3446a2d2..44d7e1ed 100644
--- a/src/guestfs-actions.c
+++ b/src/guestfs-actions.c
@@ -444,7 +444,8 @@ char **guestfs_ls (guestfs_h *g,
}
/* caller will free this, but we need to add a NULL entry */
- rv.ret.listing.listing_val = safe_realloc (g, rv.ret.listing.listing_val, rv.ret.listing.listing_len + 1);
+ rv.ret.listing.listing_val = safe_realloc (g, rv.ret.listing.listing_val,
+ sizeof (char *) * (rv.ret.listing.listing_len + 1));
rv.ret.listing.listing_val[rv.ret.listing.listing_len] = NULL;
return rv.ret.listing.listing_val;
}
@@ -517,7 +518,8 @@ char **guestfs_list_devices (guestfs_h *g)
}
/* caller will free this, but we need to add a NULL entry */
- rv.ret.devices.devices_val = safe_realloc (g, rv.ret.devices.devices_val, rv.ret.devices.devices_len + 1);
+ rv.ret.devices.devices_val = safe_realloc (g, rv.ret.devices.devices_val,
+ sizeof (char *) * (rv.ret.devices.devices_len + 1));
rv.ret.devices.devices_val[rv.ret.devices.devices_len] = NULL;
return rv.ret.devices.devices_val;
}
@@ -590,7 +592,8 @@ char **guestfs_list_partitions (guestfs_h *g)
}
/* caller will free this, but we need to add a NULL entry */
- rv.ret.partitions.partitions_val = safe_realloc (g, rv.ret.partitions.partitions_val, rv.ret.partitions.partitions_len + 1);
+ rv.ret.partitions.partitions_val = safe_realloc (g, rv.ret.partitions.partitions_val,
+ sizeof (char *) * (rv.ret.partitions.partitions_len + 1));
rv.ret.partitions.partitions_val[rv.ret.partitions.partitions_len] = NULL;
return rv.ret.partitions.partitions_val;
}
@@ -663,7 +666,8 @@ char **guestfs_pvs (guestfs_h *g)
}
/* caller will free this, but we need to add a NULL entry */
- rv.ret.physvols.physvols_val = safe_realloc (g, rv.ret.physvols.physvols_val, rv.ret.physvols.physvols_len + 1);
+ rv.ret.physvols.physvols_val = safe_realloc (g, rv.ret.physvols.physvols_val,
+ sizeof (char *) * (rv.ret.physvols.physvols_len + 1));
rv.ret.physvols.physvols_val[rv.ret.physvols.physvols_len] = NULL;
return rv.ret.physvols.physvols_val;
}
@@ -736,7 +740,8 @@ char **guestfs_vgs (guestfs_h *g)
}
/* caller will free this, but we need to add a NULL entry */
- rv.ret.volgroups.volgroups_val = safe_realloc (g, rv.ret.volgroups.volgroups_val, rv.ret.volgroups.volgroups_len + 1);
+ rv.ret.volgroups.volgroups_val = safe_realloc (g, rv.ret.volgroups.volgroups_val,
+ sizeof (char *) * (rv.ret.volgroups.volgroups_len + 1));
rv.ret.volgroups.volgroups_val[rv.ret.volgroups.volgroups_len] = NULL;
return rv.ret.volgroups.volgroups_val;
}
@@ -809,7 +814,8 @@ char **guestfs_lvs (guestfs_h *g)
}
/* caller will free this, but we need to add a NULL entry */
- rv.ret.logvols.logvols_val = safe_realloc (g, rv.ret.logvols.logvols_val, rv.ret.logvols.logvols_len + 1);
+ rv.ret.logvols.logvols_val = safe_realloc (g, rv.ret.logvols.logvols_val,
+ sizeof (char *) * (rv.ret.logvols.logvols_len + 1));
rv.ret.logvols.logvols_val[rv.ret.logvols.logvols_len] = NULL;
return rv.ret.logvols.logvols_val;
}