mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: avoid leak if dm_task_set_* fn called again
(Mikulas)
This commit is contained in:
parent
a3a5f58c21
commit
a0ca2c11ee
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.80 -
|
Version 1.02.80 -
|
||||||
==================================
|
==================================
|
||||||
|
Free any previously-set string if a dm_task_set_* function is called again.
|
||||||
Do not allow passing empty new name for dmsetup rename.
|
Do not allow passing empty new name for dmsetup rename.
|
||||||
Display any output returned by 'dmsetup message'.
|
Display any output returned by 'dmsetup message'.
|
||||||
Add dm_task_get_message_response to libdevmapper.
|
Add dm_task_get_message_response to libdevmapper.
|
||||||
|
@ -785,6 +785,7 @@ int dm_task_set_newuuid(struct dm_task *dmt, const char *newuuid)
|
|||||||
newuuid = mangled_uuid;
|
newuuid = mangled_uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dm_free(dmt->newname);
|
||||||
if (!(dmt->newname = dm_strdup(newuuid))) {
|
if (!(dmt->newname = dm_strdup(newuuid))) {
|
||||||
log_error("dm_task_set_newuuid: strdup(%s) failed", newuuid);
|
log_error("dm_task_set_newuuid: strdup(%s) failed", newuuid);
|
||||||
return 0;
|
return 0;
|
||||||
@ -796,6 +797,7 @@ int dm_task_set_newuuid(struct dm_task *dmt, const char *newuuid)
|
|||||||
|
|
||||||
int dm_task_set_message(struct dm_task *dmt, const char *message)
|
int dm_task_set_message(struct dm_task *dmt, const char *message)
|
||||||
{
|
{
|
||||||
|
dm_free(dmt->message);
|
||||||
if (!(dmt->message = dm_strdup(message))) {
|
if (!(dmt->message = dm_strdup(message))) {
|
||||||
log_error("dm_task_set_message: strdup failed");
|
log_error("dm_task_set_message: strdup failed");
|
||||||
return 0;
|
return 0;
|
||||||
@ -814,6 +816,7 @@ int dm_task_set_sector(struct dm_task *dmt, uint64_t sector)
|
|||||||
int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads,
|
int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads,
|
||||||
const char *sectors, const char *start)
|
const char *sectors, const char *start)
|
||||||
{
|
{
|
||||||
|
dm_free(dmt->geometry);
|
||||||
if (dm_asprintf(&(dmt->geometry), "%s %s %s %s",
|
if (dm_asprintf(&(dmt->geometry), "%s %s %s %s",
|
||||||
cylinders, heads, sectors, start) < 0) {
|
cylinders, heads, sectors, start) < 0) {
|
||||||
log_error("dm_task_set_geometry: sprintf failed");
|
log_error("dm_task_set_geometry: sprintf failed");
|
||||||
|
@ -720,6 +720,7 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname)
|
|||||||
newname = mangled_name;
|
newname = mangled_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dm_free(dmt->newname);
|
||||||
if (!(dmt->newname = dm_strdup(newname))) {
|
if (!(dmt->newname = dm_strdup(newname))) {
|
||||||
log_error("dm_task_set_newname: strdup(%s) failed", newname);
|
log_error("dm_task_set_newname: strdup(%s) failed", newname);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user