mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-11 12:25:52 +00:00
Fix phypOpen() escape_specialcharacters
Matthias correctly points out that escape_specialcharaters() takes a length, and since we are now malloc()'ing string in phypOpen instead of making it a static array, we can't use sizeof(string) anymore. Calculate the proper strlen and then use that both to allocate the string and also pass it to escape_specialcharacters(). Signed-off-by: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
parent
1aa1683377
commit
40d46934d0
@ -66,7 +66,7 @@ phypOpen(virConnectPtr conn,
|
|||||||
SSH_SESSION *session = NULL;
|
SSH_SESSION *session = NULL;
|
||||||
ConnectionData *connection_data = NULL;
|
ConnectionData *connection_data = NULL;
|
||||||
char *string;
|
char *string;
|
||||||
|
size_t len = 0;
|
||||||
uuid_dbPtr uuid_db = NULL;
|
uuid_dbPtr uuid_db = NULL;
|
||||||
|
|
||||||
if (!conn || !conn->uri)
|
if (!conn || !conn->uri)
|
||||||
@ -99,12 +99,14 @@ phypOpen(virConnectPtr conn,
|
|||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(string, strlen(conn->uri->path) + 1) < 0) {
|
len = strlen(conn->uri->path) + 1;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(string, len) < 0) {
|
||||||
virReportOOMError(conn);
|
virReportOOMError(conn);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (escape_specialcharacters(conn->uri->path, string, sizeof(string)) == -1) {
|
if (escape_specialcharacters(conn->uri->path, string, len) == -1) {
|
||||||
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
|
virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP,
|
||||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
|
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s",
|
||||||
_("Error parsing 'path'. Invalid characters."));
|
_("Error parsing 'path'. Invalid characters."));
|
||||||
|
Loading…
Reference in New Issue
Block a user