[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/25] util/uri: Add overflow check to rfc3986_parse
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 01/25] util/uri: Add overflow check to rfc3986_parse_port |
Date: |
Wed, 25 Feb 2015 13:08:14 -0500 |
And while at it, replace tabs by eight spaces in this function.
Signed-off-by: Max Reitz <address@hidden>
---
util/uri.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/util/uri.c b/util/uri.c
index 1cfd78b..550b984 100644
--- a/util/uri.c
+++ b/util/uri.c
@@ -320,19 +320,23 @@ static int
rfc3986_parse_port(URI *uri, const char **str)
{
const char *cur = *str;
+ int port = 0;
if (ISA_DIGIT(cur)) {
- if (uri != NULL)
- uri->port = 0;
- while (ISA_DIGIT(cur)) {
- if (uri != NULL)
- uri->port = uri->port * 10 + (*cur - '0');
- cur++;
- }
- *str = cur;
- return(0);
+ while (ISA_DIGIT(cur)) {
+ port = port * 10 + (*cur - '0');
+ if (port > 65535) {
+ return 1;
+ }
+ cur++;
+ }
+ if (uri) {
+ uri->port = port;
+ }
+ *str = cur;
+ return 0;
}
- return(1);
+ return 1;
}
/**
--
2.1.0
- [Qemu-devel] [PATCH 00/25] nbd: Several fixes, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 02/25] qemu-nbd: Detect unused partitions by system == 0, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 03/25] nbd: Fix nbd_establish_connection()'s return value, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 05/25] nbd: Avoid generic -EINVAL, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 08/25] nbd: Handle blk_getlength() failure, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 01/25] util/uri: Add overflow check to rfc3986_parse_port,
Max Reitz <=
- [Qemu-devel] [PATCH 09/25] qemu-nbd: fork() can fail, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 14/25] coroutine: Add co_yield_timeout(), Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 06/25] nbd: Pass return value from nbd_handle_list(), Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 04/25] nbd: Fix response to invalid requests, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 15/25] coroutine-io: Return -errno in case of error, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 10/25] nbd: Fix potential signed overflow issues, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 07/25] nbd: Add "failed to open export" error message, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 12/25] nbd: Set block size to BDRV_SECTOR_SIZE, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 13/25] nbd: Enforce sector alignment, Max Reitz, 2015/02/25
- [Qemu-devel] [PATCH 21/25] nbd: Drop unexpected data for NBD_OPT_LIST, Max Reitz, 2015/02/25