]> andersk Git - openssh.git/blobdiff - channels.c
- djm@cvs.openbsd.org 2006/04/16 00:48:52
[openssh.git] / channels.c
index 57634a21d939ecf466133584f6f4492b4501a0f0..2fa997edc991642ba6acbf03fff2f3d9c0bb2798 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: channels.c,v 1.246 2006/03/25 18:56:54 deraadt Exp $ */
+/* $OpenBSD: channels.c,v 1.250 2006/04/16 00:48:52 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -747,12 +747,10 @@ channel_pre_open(Channel *c, fd_set *readset, fd_set *writeset)
 {
        u_int limit = compat20 ? c->remote_window : packet_get_maxsize();
 
-       /* check buffer limits */
-       limit = MIN(limit, (BUFFER_MAX_LEN - BUFFER_MAX_CHUNK - CHAN_RBUF));
-
        if (c->istate == CHAN_INPUT_OPEN &&
            limit > 0 &&
-           buffer_len(&c->input) < limit)
+           buffer_len(&c->input) < limit &&
+           buffer_check_alloc(&c->input, CHAN_RBUF))
                FD_SET(c->rfd, readset);
        if (c->ostate == CHAN_OUTPUT_OPEN ||
            c->ostate == CHAN_OUTPUT_WAIT_DRAIN) {
@@ -1049,7 +1047,7 @@ channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset)
        debug2("channel %d: socks5 post auth", c->self);
        if (have < sizeof(s5_req)+1)
                return 0;                       /* need more */
-       memcpy((char *)&s5_req, p, sizeof(s5_req));
+       memcpy(&s5_req, p, sizeof(s5_req));
        if (s5_req.version != 0x05 ||
            s5_req.command != SSH_SOCKS5_CONNECT ||
            s5_req.reserved != 0x00) {
@@ -1945,6 +1943,8 @@ channel_output_poll(void)
 
 
 /* -- protocol input */
+
+/* ARGSUSED */
 void
 channel_input_data(int type, u_int32_t seq, void *ctxt)
 {
@@ -2004,6 +2004,7 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
        xfree(data);
 }
 
+/* ARGSUSED */
 void
 channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
 {
@@ -2050,6 +2051,7 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
        xfree(data);
 }
 
+/* ARGSUSED */
 void
 channel_input_ieof(int type, u_int32_t seq, void *ctxt)
 {
@@ -2073,6 +2075,7 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt)
 
 }
 
+/* ARGSUSED */
 void
 channel_input_close(int type, u_int32_t seq, void *ctxt)
 {
@@ -2111,6 +2114,7 @@ channel_input_close(int type, u_int32_t seq, void *ctxt)
 }
 
 /* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */
+/* ARGSUSED */
 void
 channel_input_oclose(int type, u_int32_t seq, void *ctxt)
 {
@@ -2123,6 +2127,7 @@ channel_input_oclose(int type, u_int32_t seq, void *ctxt)
        chan_rcvd_oclose(c);
 }
 
+/* ARGSUSED */
 void
 channel_input_close_confirmation(int type, u_int32_t seq, void *ctxt)
 {
@@ -2139,6 +2144,7 @@ channel_input_close_confirmation(int type, u_int32_t seq, void *ctxt)
        channel_free(c);
 }
 
+/* ARGSUSED */
 void
 channel_input_open_confirmation(int type, u_int32_t seq, void *ctxt)
 {
@@ -2186,6 +2192,7 @@ reason2txt(int reason)
        return "unknown reason";
 }
 
+/* ARGSUSED */
 void
 channel_input_open_failure(int type, u_int32_t seq, void *ctxt)
 {
@@ -2217,6 +2224,7 @@ channel_input_open_failure(int type, u_int32_t seq, void *ctxt)
        channel_free(c);
 }
 
+/* ARGSUSED */
 void
 channel_input_window_adjust(int type, u_int32_t seq, void *ctxt)
 {
@@ -2241,6 +2249,7 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt)
        c->remote_window += adjust;
 }
 
+/* ARGSUSED */
 void
 channel_input_port_open(int type, u_int32_t seq, void *ctxt)
 {
@@ -2886,12 +2895,12 @@ connect_local_xsocket(u_int dnr)
 int
 x11_connect_display(void)
 {
-       int display_number, sock = 0;
+       u_int display_number;
        const char *display;
        char buf[1024], *cp;
        struct addrinfo hints, *ai, *aitop;
        char strport[NI_MAXSERV];
-       int gaierr;
+       int gaierr, sock = 0;
 
        /* Try to open a socket for the local X server. */
        display = getenv("DISPLAY");
@@ -2911,7 +2920,7 @@ x11_connect_display(void)
        if (strncmp(display, "unix:", 5) == 0 ||
            display[0] == ':') {
                /* Connect to the unix domain socket. */
-               if (sscanf(strrchr(display, ':') + 1, "%d", &display_number) != 1) {
+               if (sscanf(strrchr(display, ':') + 1, "%u", &display_number) != 1) {
                        error("Could not parse display number from DISPLAY: %.100s",
                            display);
                        return -1;
@@ -2936,7 +2945,7 @@ x11_connect_display(void)
        }
        *cp = 0;
        /* buf now contains the host name.  But first we parse the display number. */
-       if (sscanf(cp + 1, "%d", &display_number) != 1) {
+       if (sscanf(cp + 1, "%u", &display_number) != 1) {
                error("Could not parse display number from DISPLAY: %.100s",
                    display);
                return -1;
@@ -2946,7 +2955,7 @@ x11_connect_display(void)
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = IPv4or6;
        hints.ai_socktype = SOCK_STREAM;
-       snprintf(strport, sizeof strport, "%d", 6000 + display_number);
+       snprintf(strport, sizeof strport, "%u", 6000 + display_number);
        if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) {
                error("%.100s: unknown host. (%s)", buf, gai_strerror(gaierr));
                return -1;
@@ -2960,7 +2969,7 @@ x11_connect_display(void)
                }
                /* Connect it to the display. */
                if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
-                       debug2("connect %.100s port %d: %.100s", buf,
+                       debug2("connect %.100s port %u: %.100s", buf,
                            6000 + display_number, strerror(errno));
                        close(sock);
                        continue;
@@ -2970,7 +2979,7 @@ x11_connect_display(void)
        }
        freeaddrinfo(aitop);
        if (!ai) {
-               error("connect %.100s port %d: %.100s", buf, 6000 + display_number,
+               error("connect %.100s port %u: %.100s", buf, 6000 + display_number,
                    strerror(errno));
                return -1;
        }
This page took 0.041815 seconds and 4 git commands to generate.