aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2011-02-02 05:02:04 +0100
committermilo <milo@r0ot.me>2011-02-04 12:46:51 +0100
commit867944b939383baf28f573ee7ee3ba03805b25eb (patch)
tree976edd2031be603aff5e03254c98f37cc2b4683e /src
parentb0c2be25a6f2f69f11cf0379b6f8a1f0e7646b3a (diff)
downloadlibssh-867944b939383baf28f573ee7ee3ba03805b25eb.tar.gz
libssh-867944b939383baf28f573ee7ee3ba03805b25eb.tar.xz
libssh-867944b939383baf28f573ee7ee3ba03805b25eb.zip
Respect RFC when sending stderr data
http://tools.ietf.org/html/rfc4254#section-5.2 byte SSH_MSG_CHANNEL_EXTENDED_DATA uint32 recipient channel *uint32 data_type_code* string data
Diffstat (limited to 'src')
-rw-r--r--src/channels.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/channels.c b/src/channels.c
index 5ee7b845..a886f941 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -1120,8 +1120,16 @@ int channel_write_common(ssh_channel channel, const void *data,
if (buffer_add_u8(session->out_buffer, is_stderr ?
SSH2_MSG_CHANNEL_EXTENDED_DATA : SSH2_MSG_CHANNEL_DATA) < 0 ||
buffer_add_u32(session->out_buffer,
- htonl(channel->remote_channel)) < 0 ||
- buffer_add_u32(session->out_buffer, htonl(effectivelen)) < 0 ||
+ htonl(channel->remote_channel)) < 0) {
+ goto error;
+ }
+ /* stderr message has an extra field */
+ if (is_stderr &&
+ buffer_add_u32(session->out_buffer, htonl(SSH2_EXTENDED_DATA_STDERR)) < 0) {
+ goto error;
+ }
+ /* append payload data */
+ if (buffer_add_u32(session->out_buffer, htonl(effectivelen)) < 0 ||
buffer_add_data(session->out_buffer, data, effectivelen) < 0) {
goto error;
}