forked from openssh/openssh-portable
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: client: switch to sshbuf API; ok djm@
OpenBSD-Commit-ID: 60cb0356114acc7625ab85105f6f6a7cd44a8d05
- Loading branch information
Showing
8 changed files
with
416 additions
and
328 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: clientloop.h,v 1.35 2017/10/23 05:08:00 djm Exp $ */ | ||
/* $OpenBSD: clientloop.h,v 1.36 2018/07/09 21:03:30 markus Exp $ */ | ||
|
||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
|
@@ -45,7 +45,7 @@ int client_x11_get_proto(struct ssh *, const char *, const char *, | |
u_int, u_int, char **, char **); | ||
void client_global_request_reply_fwd(int, u_int32_t, void *); | ||
void client_session2_setup(struct ssh *, int, int, int, | ||
const char *, struct termios *, int, Buffer *, char **); | ||
const char *, struct termios *, int, struct sshbuf *, char **); | ||
char *client_request_tun_fwd(struct ssh *, int, int, int); | ||
void client_stop_mux(void); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: mux.c,v 1.71 2018/06/09 03:01:12 djm Exp $ */ | ||
/* $OpenBSD: mux.c,v 1.72 2018/07/09 21:03:30 markus Exp $ */ | ||
/* | ||
* Copyright (c) 2002-2008 Damien Miller <[email protected]> | ||
* | ||
|
@@ -87,7 +87,7 @@ extern Options options; | |
extern int stdin_null_flag; | ||
extern char *host; | ||
extern int subsystem_flag; | ||
extern Buffer command; | ||
extern struct sshbuf *command; | ||
extern volatile sig_atomic_t quit_pending; | ||
|
||
/* Context for session open confirmation callback */ | ||
|
@@ -1887,7 +1887,7 @@ mux_client_request_session(int fd) | |
buffer_put_int(&m, options.escape_char == SSH_ESCAPECHAR_NONE ? | ||
0xffffffff : (u_int)options.escape_char); | ||
buffer_put_cstring(&m, term == NULL ? "" : term); | ||
buffer_put_string(&m, buffer_ptr(&command), buffer_len(&command)); | ||
buffer_put_string(&m, buffer_ptr(command), buffer_len(command)); | ||
|
||
/* Pass environment */ | ||
if (options.num_send_env > 0 && environ != NULL) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: packet.c,v 1.275 2018/07/09 13:37:10 sf Exp $ */ | ||
/* $OpenBSD: packet.c,v 1.276 2018/07/09 21:03:30 markus Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -63,9 +63,6 @@ | |
|
||
#include <zlib.h> | ||
|
||
#include "buffer.h" /* typedefs XXX */ | ||
#include "key.h" /* typedefs XXX */ | ||
|
||
#include "xmalloc.h" | ||
#include "crc32.h" | ||
#include "compat.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: ssh.c,v 1.481 2018/06/08 03:35:36 djm Exp $ */ | ||
/* $OpenBSD: ssh.c,v 1.482 2018/07/09 21:03:30 markus Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -87,7 +87,7 @@ | |
#include "cipher.h" | ||
#include "digest.h" | ||
#include "packet.h" | ||
#include "buffer.h" | ||
#include "sshbuf.h" | ||
#include "channels.h" | ||
#include "key.h" | ||
#include "authfd.h" | ||
|
@@ -183,7 +183,7 @@ uid_t original_real_uid; | |
uid_t original_effective_uid; | ||
|
||
/* command to be executed */ | ||
Buffer command; | ||
struct sshbuf *command; | ||
|
||
/* Should we execute a command or invoke a subsystem? */ | ||
int subsystem_flag = 0; | ||
|
@@ -1042,7 +1042,8 @@ main(int ac, char **av) | |
#endif | ||
|
||
/* Initialize the command to execute on remote host. */ | ||
buffer_init(&command); | ||
if ((command = sshbuf_new()) == NULL) | ||
fatal("sshbuf_new failed"); | ||
|
||
/* | ||
* Save the command to execute on the remote host in a buffer. There | ||
|
@@ -1059,9 +1060,10 @@ main(int ac, char **av) | |
} else { | ||
/* A command has been specified. Store it into the buffer. */ | ||
for (i = 0; i < ac; i++) { | ||
if (i) | ||
buffer_append(&command, " ", 1); | ||
buffer_append(&command, av[i], strlen(av[i])); | ||
if ((r = sshbuf_putf(command, "%s%s", | ||
i ? " " : "", av[i])) != 0) | ||
fatal("%s: buffer error: %s", | ||
__func__, ssh_err(r)); | ||
} | ||
} | ||
|
||
|
@@ -1234,11 +1236,11 @@ main(int ac, char **av) | |
options.use_privileged_port = 0; | ||
#endif | ||
|
||
if (buffer_len(&command) != 0 && options.remote_command != NULL) | ||
if (sshbuf_len(command) != 0 && options.remote_command != NULL) | ||
fatal("Cannot execute command-line and remote command."); | ||
|
||
/* Cannot fork to background if no command. */ | ||
if (fork_after_authentication_flag && buffer_len(&command) == 0 && | ||
if (fork_after_authentication_flag && sshbuf_len(command) == 0 && | ||
options.remote_command == NULL && !no_shell_flag) | ||
fatal("Cannot fork into background without a command " | ||
"to execute."); | ||
|
@@ -1251,7 +1253,7 @@ main(int ac, char **av) | |
tty_flag = 1; | ||
|
||
/* Allocate a tty by default if no command specified. */ | ||
if (buffer_len(&command) == 0 && options.remote_command == NULL) | ||
if (sshbuf_len(command) == 0 && options.remote_command == NULL) | ||
tty_flag = options.request_tty != REQUEST_TTY_NO; | ||
|
||
/* Force no tty */ | ||
|
@@ -1313,8 +1315,9 @@ main(int ac, char **av) | |
(char *)NULL); | ||
debug3("expanded RemoteCommand: %s", options.remote_command); | ||
free(cp); | ||
buffer_append(&command, options.remote_command, | ||
strlen(options.remote_command)); | ||
if ((r = sshbuf_put(command, options.remote_command, | ||
strlen(options.remote_command))) != 0) | ||
fatal("%s: buffer error: %s", __func__, ssh_err(r)); | ||
} | ||
|
||
if (options.control_path != NULL) { | ||
|
@@ -1846,7 +1849,7 @@ ssh_session2_setup(struct ssh *ssh, int id, int success, void *arg) | |
options.ip_qos_interactive, options.ip_qos_bulk); | ||
|
||
client_session2_setup(ssh, id, tty_flag, subsystem_flag, getenv("TERM"), | ||
NULL, fileno(stdin), &command, environ); | ||
NULL, fileno(stdin), command, environ); | ||
} | ||
|
||
/* open new channel for a session */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: sshconnect.c,v 1.298 2018/04/10 00:10:49 djm Exp $ */ | ||
/* $OpenBSD: sshconnect.c,v 1.299 2018/07/09 21:03:30 markus Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -52,7 +52,7 @@ | |
#include "key.h" | ||
#include "hostfile.h" | ||
#include "ssh.h" | ||
#include "buffer.h" | ||
#include "sshbuf.h" | ||
#include "packet.h" | ||
#include "uidswap.h" | ||
#include "compat.h" | ||
|
@@ -771,7 +771,7 @@ check_host_cert(const char *host, const struct sshkey *host_key) | |
error("%s", reason); | ||
return 0; | ||
} | ||
if (buffer_len(host_key->cert->critical) != 0) { | ||
if (sshbuf_len(host_key->cert->critical) != 0) { | ||
error("Certificate for %s contains unsupported " | ||
"critical options(s)", host); | ||
return 0; | ||
|
Oops, something went wrong.