mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 23:25:48 +00:00
util/uri: Add overflow check to rfc3986_parse_port
And while at it, replace tabs by eight spaces in this function. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <1424887718-10800-2-git-send-email-mreitz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
24
util/uri.c
24
util/uri.c
@ -320,19 +320,23 @@ static int
|
|||||||
rfc3986_parse_port(URI *uri, const char **str)
|
rfc3986_parse_port(URI *uri, const char **str)
|
||||||
{
|
{
|
||||||
const char *cur = *str;
|
const char *cur = *str;
|
||||||
|
int port = 0;
|
||||||
|
|
||||||
if (ISA_DIGIT(cur)) {
|
if (ISA_DIGIT(cur)) {
|
||||||
if (uri != NULL)
|
while (ISA_DIGIT(cur)) {
|
||||||
uri->port = 0;
|
port = port * 10 + (*cur - '0');
|
||||||
while (ISA_DIGIT(cur)) {
|
if (port > 65535) {
|
||||||
if (uri != NULL)
|
return 1;
|
||||||
uri->port = uri->port * 10 + (*cur - '0');
|
}
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
*str = cur;
|
if (uri) {
|
||||||
return(0);
|
uri->port = port;
|
||||||
|
}
|
||||||
|
*str = cur;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user