mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
viruri: Search params case insensitively
Our URI handling code (doRemoteOpen() specifically), uses case insensitive parsing of query part of URI. For instance: qemu:///system?socket=/some/path qemu:///system?SoCkEt=/some/path are the same URI. Even though the latter is probably not used anywhere, let's switch to STRCASEEQ() instead of STREQ() at two places: virURIGetParam() and virURICheckUnixSocket(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
917749314c
commit
65b9d9a619
@ -365,13 +365,24 @@ virURIResolveAlias(virConf *conf, const char *alias, char **uri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virURIGetParam:
|
||||||
|
* @uri: URI to get parameter from
|
||||||
|
* @name: name of the parameter
|
||||||
|
*
|
||||||
|
* For parsed @uri, find parameter with name @name and return its value. The
|
||||||
|
* string comparison is case insensitive, by design.
|
||||||
|
*
|
||||||
|
* Returns: a value on success, or
|
||||||
|
* NULL on error (with error reported)
|
||||||
|
*/
|
||||||
const char *
|
const char *
|
||||||
virURIGetParam(virURI *uri, const char *name)
|
virURIGetParam(virURI *uri, const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < uri->paramsCount; i++) {
|
for (i = 0; i < uri->paramsCount; i++) {
|
||||||
if (STREQ(uri->params[i].name, name))
|
if (STRCASEEQ(uri->params[i].name, name))
|
||||||
return uri->params[i].value;
|
return uri->params[i].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,6 +400,8 @@ virURIGetParam(virURI *uri, const char *name)
|
|||||||
* scenario the socket might be proxied to a remote server even though the URI
|
* scenario the socket might be proxied to a remote server even though the URI
|
||||||
* looks like it is only local.
|
* looks like it is only local.
|
||||||
*
|
*
|
||||||
|
* The "socket" parameter is looked for in case insensitive manner, by design.
|
||||||
|
*
|
||||||
* Returns: true if the URI might be proxied to a remote server
|
* Returns: true if the URI might be proxied to a remote server
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
@ -403,7 +416,7 @@ virURICheckUnixSocket(virURI *uri)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < uri->paramsCount; i++) {
|
for (i = 0; i < uri->paramsCount; i++) {
|
||||||
if (STREQ(uri->params[i].name, "socket"))
|
if (STRCASEEQ(uri->params[i].name, "socket"))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user