|
|
d9d99f |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
d9d99f |
From: Aaron Miller <aaronmiller@fb.com>
|
|
|
d9d99f |
Date: Fri, 29 Jul 2016 17:41:38 +0800
|
|
|
d9d99f |
Subject: [PATCH] net: read bracketed ipv6 addrs and port numbers (pjones
|
|
|
d9d99f |
fixup)
|
|
|
d9d99f |
|
|
|
d9d99f |
Various bug fixes related to previous patch.
|
|
|
d9d99f |
|
|
|
d9d99f |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
d9d99f |
---
|
|
|
d9d99f |
grub-core/net/http.c | 6 ++++--
|
|
|
d9d99f |
grub-core/net/net.c | 24 ++++++++++++------------
|
|
|
d9d99f |
2 files changed, 16 insertions(+), 14 deletions(-)
|
|
|
d9d99f |
|
|
|
d9d99f |
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
|
|
|
d9d99f |
index f182d7b871d..00737c52750 100644
|
|
|
d9d99f |
--- a/grub-core/net/http.c
|
|
|
d9d99f |
+++ b/grub-core/net/http.c
|
|
|
d9d99f |
@@ -289,7 +289,9 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)),
|
|
|
d9d99f |
nb2 = grub_netbuff_alloc (data->chunk_rem);
|
|
|
d9d99f |
if (!nb2)
|
|
|
d9d99f |
return grub_errno;
|
|
|
d9d99f |
- grub_netbuff_put (nb2, data->chunk_rem);
|
|
|
d9d99f |
+ err = grub_netbuff_put (nb2, data->chunk_rem);
|
|
|
d9d99f |
+ if (err)
|
|
|
d9d99f |
+ return grub_errno;
|
|
|
d9d99f |
grub_memcpy (nb2->data, nb->data, data->chunk_rem);
|
|
|
d9d99f |
if (file->device->net->packs.count >= 20)
|
|
|
d9d99f |
{
|
|
|
d9d99f |
@@ -405,7 +407,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
|
|
|
d9d99f |
data->filename, server, port ? port : HTTP_PORT);
|
|
|
d9d99f |
data->sock = grub_net_tcp_open (server,
|
|
|
d9d99f |
port ? port : HTTP_PORT, http_receive,
|
|
|
d9d99f |
- http_err, http_err,
|
|
|
d9d99f |
+ http_err, NULL,
|
|
|
d9d99f |
file);
|
|
|
d9d99f |
if (!data->sock)
|
|
|
d9d99f |
{
|
|
|
d9d99f |
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
|
|
d9d99f |
index 1f887d44b32..a0f4d00f0be 100644
|
|
|
d9d99f |
--- a/grub-core/net/net.c
|
|
|
d9d99f |
+++ b/grub-core/net/net.c
|
|
|
d9d99f |
@@ -441,10 +441,11 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest)
|
|
|
d9d99f |
int word, quaddot = -1;
|
|
|
d9d99f |
int bracketed = 0;
|
|
|
d9d99f |
|
|
|
d9d99f |
- if (ptr[0] == '[') {
|
|
|
d9d99f |
- bracketed = 1;
|
|
|
d9d99f |
- ptr++;
|
|
|
d9d99f |
- }
|
|
|
d9d99f |
+ if (ptr[0] == '[')
|
|
|
d9d99f |
+ {
|
|
|
d9d99f |
+ bracketed = 1;
|
|
|
d9d99f |
+ ptr++;
|
|
|
d9d99f |
+ }
|
|
|
d9d99f |
|
|
|
d9d99f |
if (ptr[0] == ':' && ptr[1] != ':')
|
|
|
d9d99f |
return 0;
|
|
|
d9d99f |
@@ -483,9 +484,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest)
|
|
|
d9d99f |
grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0]));
|
|
|
d9d99f |
}
|
|
|
d9d99f |
grub_memcpy (ip, newip, 16);
|
|
|
d9d99f |
- if (bracketed && *ptr == ']') {
|
|
|
d9d99f |
+ if (bracketed && *ptr == ']')
|
|
|
d9d99f |
ptr++;
|
|
|
d9d99f |
- }
|
|
|
d9d99f |
if (rest)
|
|
|
d9d99f |
*rest = ptr;
|
|
|
d9d99f |
return 1;
|
|
|
d9d99f |
@@ -1389,7 +1389,7 @@ grub_net_open_real (const char *name)
|
|
|
d9d99f |
char* port_start;
|
|
|
d9d99f |
/* ipv6 or port specified? */
|
|
|
d9d99f |
if ((port_start = grub_strchr (server, ':')))
|
|
|
d9d99f |
- {
|
|
|
d9d99f |
+ {
|
|
|
d9d99f |
char* ipv6_begin;
|
|
|
d9d99f |
if((ipv6_begin = grub_strchr (server, '[')))
|
|
|
d9d99f |
{
|
|
|
d9d99f |
@@ -1461,14 +1461,13 @@ grub_net_open_real (const char *name)
|
|
|
d9d99f |
{
|
|
|
d9d99f |
grub_net_t ret = grub_zalloc (sizeof (*ret));
|
|
|
d9d99f |
if (!ret)
|
|
|
d9d99f |
- return NULL;
|
|
|
d9d99f |
- ret->protocol = proto;
|
|
|
d9d99f |
- ret->server = grub_strdup (server);
|
|
|
d9d99f |
- if (!ret->server)
|
|
|
d9d99f |
{
|
|
|
d9d99f |
- grub_free (ret);
|
|
|
d9d99f |
+ grub_free (host);
|
|
|
d9d99f |
return NULL;
|
|
|
d9d99f |
}
|
|
|
d9d99f |
+ ret->protocol = proto;
|
|
|
d9d99f |
+ ret->port = port;
|
|
|
d9d99f |
+ ret->server = host;
|
|
|
d9d99f |
ret->fs = &grub_net_fs;
|
|
|
d9d99f |
return ret;
|
|
|
d9d99f |
}
|
|
|
d9d99f |
@@ -1543,6 +1542,7 @@ grub_net_open_real (const char *name)
|
|
|
d9d99f |
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
|
|
|
d9d99f |
name);
|
|
|
d9d99f |
|
|
|
d9d99f |
+ grub_free (host);
|
|
|
d9d99f |
return NULL;
|
|
|
d9d99f |
}
|
|
|
d9d99f |
|