libnbd/0018-lib-uri.c-Fix-indices-in-SSH-command-array.patch

60 lines
2.1 KiB
Diff

From f130e5f9554d669791555f330b63353a1a181ca1 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 23 Oct 2025 11:58:53 +0100
Subject: [PATCH] lib/uri.c: Fix indices in SSH command array
Commit f461fe64d2 ("uri: Sanitize user-provided hostnames") didn't
update the fixed indices that we use to access the SSH command array
(this is no longer a problem in upstream code).
'tests/connect-uri-nbd-ssh' failed with:
libnbd: debug: nbd1: nbd_connect_uri: poll start: events=1
bash: -U: invalid option
Usage: bash [GNU long option] [option] ...
bash [GNU long option] [option] script-file ...
[...]
Fixes: commit f461fe64d21fe8a6d32b56ccb50d06489d2e2698
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit 00181d26a4d891e2d7acdd0a309fbf2af01eb55e)
---
lib/uri.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/uri.c b/lib/uri.c
index 5afd0f49..9cbec2df 100644
--- a/lib/uri.c
+++ b/lib/uri.c
@@ -448,8 +448,8 @@ nbd_unlocked_aio_connect_uri (struct nbd_handle *h, const char *raw_uri)
const char *ssh_command[] = {
"ssh", "-p", port_str, "--", uri->server,
"nc",
- NULL, /* [5] "-U" or "localhost" */
- NULL, /* [6] socket or "10809" */
+ NULL, /* [6] "-U" or "localhost" */
+ NULL, /* [7] socket or "10809" */
NULL,
};
@@ -461,12 +461,12 @@ nbd_unlocked_aio_connect_uri (struct nbd_handle *h, const char *raw_uri)
"%d", uri->port > 0 ? uri->port : 22);
if (unixsocket) {
- ssh_command[5] = "-U";
- ssh_command[6] = unixsocket;
+ ssh_command[6] = "-U";
+ ssh_command[7] = unixsocket;
}
else {
- ssh_command[5] = "localhost";
- ssh_command[6] = "10809"; /* XXX provide a way to configure this */
+ ssh_command[6] = "localhost";
+ ssh_command[7] = "10809"; /* XXX provide a way to configure this */
}
if (nbd_unlocked_aio_connect_command (h, (char **) ssh_command) == -1)
--
2.47.3