Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pF1bb-0000kK-0C for mharc-grub-devel@gnu.org; Mon, 09 Jan 2023 18:31:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF1bZ-0000jv-JD for grub-devel@gnu.org; Mon, 09 Jan 2023 18:31:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF1bX-0003MM-Hb for grub-devel@gnu.org; Mon, 09 Jan 2023 18:31:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673307058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Le9/Hn+wuhTZwdNmuSC1jwgKXLMP1bUt0hh9PIakFvs=; b=cNC72O3+SyrAmLuGEuOSbHKC+IK0UhpD0jvJXDBt6WK9jd4jZ+sa4dC5dpkEPPvay4IEBE ACRXktBboE5/5ZArLTJgYV9qMDYn4PBsDu1T3IJEibHaZ3wd7dct16C7wnwRDOYghfjD14 xEZ/wd3ReyLDrglFZxlOZtMm9mZk1o0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-aP9q47GdPRqjTF4fHZzA1g-1; Mon, 09 Jan 2023 18:30:56 -0500 X-MC-Unique: aP9q47GdPRqjTF4fHZzA1g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87F7E1C05146; Mon, 9 Jan 2023 23:30:56 +0000 (UTC) Received: from eesha.redhat.com (unknown [10.22.9.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 670BB40C2064; Mon, 9 Jan 2023 23:30:56 +0000 (UTC) From: Robbie Harwood To: grub-devel@gnu.org Cc: Robbie Harwood , dkiper@net-space.pl Subject: [PATCH v4 01/19] Revert "net/http: Allow use of non-standard TCP/IP ports" Date: Mon, 9 Jan 2023 18:30:27 -0500 Message-Id: <20230109233045.85477-2-rharwood@redhat.com> In-Reply-To: <20230109233045.85477-1-rharwood@redhat.com> References: <20230109233045.85477-1-rharwood@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Received-SPF: pass client-ip=170.10.129.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2023 23:31:01 -0000 This reverts commit ac8a37dda0eabdd80506bebe4fb9a5a9fd227935. Signed-off-by: Robbie Harwood --- docs/grub.texi | 33 --------------------------------- grub-core/net/http.c | 40 ++-------------------------------------- 2 files changed, 2 insertions(+), 71 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 50c811a88e..ed295dabd2 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3053,39 +3053,6 @@ environment variable @samp{net_default_server} is used. Before using the network drive, you must initialize the network. @xref{Network}, for more information. -For the @samp{http} network protocol, @code{@var{server}} may specify a -port number other than the default value of @samp{80}. The server name -and port number are separated by either @samp{,} or @samp{:}. -For IPv6 addresses, the server name and port number may only be separated -by @samp{,}. - -@itemize @bullet -@item -@code{(http,@var{server},@var{port})} - -@item -@code{(http,@var{server}:@var{port})} -@end itemize - -These examples all reference an @samp{http} server at address -@samp{192.0.2.1} listening on the non-standard port of @samp{3000}. -In these examples, the DNS name @samp{grub.example.com} is resolved -to @samp{192.0.2.1}. - -@example -(http,grub.example.com,3000) -(http,grub.example.com:3000) -(http,192.0.2.1,3000) -(http,192.0.2.1:3000) -@end example - -Referencing an @samp{http} server over IPv6 on the non-standard -port of @samp{3000} would look like this: - -@example -(http,2001:db8::1,3000) -@end example - If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Making a GRUB bootable CD-ROM}, for details. diff --git a/grub-core/net/http.c b/grub-core/net/http.c index 9291a13e2d..d67cad4829 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -318,10 +318,6 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) int i; struct grub_net_buff *nb; grub_err_t err; - char *server_name; - char *port_string; - const char *port_string_end; - unsigned long port_number; nb = grub_netbuff_alloc (GRUB_NET_TCP_RESERVE_SIZE + sizeof ("GET ") - 1 @@ -400,42 +396,10 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) grub_netbuff_put (nb, 2); grub_memcpy (ptr, "\r\n", 2); - port_string = grub_strrchr (file->device->net->server, ','); - if (port_string == NULL) - { - /* If ",port" is not found in the http server string, look for ":port". */ - port_string = grub_strrchr (file->device->net->server, ':'); - /* For IPv6 addresses, the ":port" syntax is not supported and ",port" must be used. */ - if (port_string != NULL && grub_strchr (file->device->net->server, ':') != port_string) - port_string = NULL; - } - if (port_string != NULL) - { - port_number = grub_strtoul (port_string + 1, &port_string_end, 10); - if (*(port_string + 1) == '\0' || *port_string_end != '\0') - return grub_error (GRUB_ERR_BAD_NUMBER, N_("non-numeric or invalid port number `%s'"), port_string + 1); - if (port_number == 0 || port_number > 65535) - return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("port number `%s' not in the range of 1 to 65535"), port_string + 1); - - server_name = grub_strdup (file->device->net->server); - if (server_name == NULL) - return grub_errno; - server_name[port_string - file->device->net->server] = '\0'; - } - else - { - port_number = HTTP_PORT; - server_name = file->device->net->server; - } - - data->sock = grub_net_tcp_open (server_name, - port_number, http_receive, + data->sock = grub_net_tcp_open (file->device->net->server, + HTTP_PORT, http_receive, http_err, NULL, file); - - if (server_name != file->device->net->server) - grub_free (server_name); - if (!data->sock) { grub_netbuff_free (nb); -- 2.39.0