提交 fa4fc032 编写于 作者: J Jim Meyering

fix inadequate initialization in storage and test drivers

* src/storage_driver.c (storageListPools): Set all "names" entries to 0.
(storageListDefinedPools, storagePoolListVolumes): Likewise.
* src/test.c (testStoragePoolListVolumes): Likewise.
上级 a904a56c
Tue, 2 Dec 2008 16:58:16 +0100 Jim Meyering <meyering@redhat.com>
fix inadequate initialization in storage and test drivers
* src/storage_driver.c (storageListPools): Set all "names" entries to 0.
(storageListDefinedPools, storagePoolListVolumes): Likewise.
* src/test.c (testStoragePoolListVolumes): Likewise.
Tue Dec 2 13:45:00 CET 2008 Chris Lalancette <clalance@redhat.com>
* configure.in, src/storage_backend.c: Older distributions (i.e.
RHEL-5) don't have udevadm at all, but they do have udevsettle. So
......
......@@ -347,7 +347,7 @@ storageListPools(virConnectPtr conn,
free(names[i]);
names[i] = NULL;
}
memset(names, 0, nnames);
memset(names, 0, nnames * sizeof(*names));
return -1;
}
......@@ -389,7 +389,7 @@ storageListDefinedPools(virConnectPtr conn,
free(names[i]);
names[i] = NULL;
}
memset(names, 0, nnames);
memset(names, 0, nnames * sizeof(*names));
return -1;
}
......@@ -880,7 +880,7 @@ storagePoolListVolumes(virStoragePoolPtr obj,
return -1;
}
memset(names, 0, maxnames);
memset(names, 0, maxnames * sizeof(*names));
for (i = 0 ; i < pool->volumes.count && n < maxnames ; i++) {
if ((names[n++] = strdup(pool->volumes.objs[i]->name)) == NULL) {
virStorageReportError(obj->conn, VIR_ERR_NO_MEMORY,
......@@ -895,7 +895,7 @@ storagePoolListVolumes(virStoragePoolPtr obj,
for (n = 0 ; n < maxnames ; n++)
VIR_FREE(names[i]);
memset(names, 0, maxnames);
memset(names, 0, maxnames * sizeof(*names));
return -1;
}
......
......@@ -1951,7 +1951,7 @@ testStoragePoolListVolumes(virStoragePoolPtr obj,
POOL_IS_ACTIVE(privpool, -1);
int i = 0, n = 0;
memset(names, 0, maxnames);
memset(names, 0, maxnames * sizeof(*names));
for (i = 0 ; i < privpool->volumes.count && n < maxnames ; i++) {
if ((names[n++] = strdup(privpool->volumes.objs[i]->name)) == NULL) {
testError(obj->conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
......@@ -1965,7 +1965,7 @@ testStoragePoolListVolumes(virStoragePoolPtr obj,
for (n = 0 ; n < maxnames ; n++)
VIR_FREE(names[i]);
memset(names, 0, maxnames);
memset(names, 0, maxnames * sizeof(*names));
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册