[BACK]Return to sftp-client.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sftp-client.c between version 1.51 and 1.51.2.3

version 1.51, 2004/07/11 17:48:47 version 1.51.2.3, 2005/09/02 03:45:00
Line 64 
Line 64 
   
         /* Send length first */          /* Send length first */
         PUT_32BIT(mlen, buffer_len(m));          PUT_32BIT(mlen, buffer_len(m));
         if (atomicio(vwrite, fd, mlen, sizeof(mlen)) <= 0)          if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen))
                 fatal("Couldn't send packet: %s", strerror(errno));                  fatal("Couldn't send packet: %s", strerror(errno));
   
         if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) <= 0)          if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) != buffer_len(m))
                 fatal("Couldn't send packet: %s", strerror(errno));                  fatal("Couldn't send packet: %s", strerror(errno));
   
         buffer_clear(m);          buffer_clear(m);
Line 76 
Line 76 
 static void  static void
 get_msg(int fd, Buffer *m)  get_msg(int fd, Buffer *m)
 {  {
         ssize_t len;  
         u_int msg_len;          u_int msg_len;
   
         buffer_append_space(m, 4);          buffer_append_space(m, 4);
         len = atomicio(read, fd, buffer_ptr(m), 4);          if (atomicio(read, fd, buffer_ptr(m), 4) != 4) {
         if (len == 0)                  if (errno == EPIPE)
                 fatal("Connection closed");                          fatal("Connection closed");
         else if (len == -1)                  else
                 fatal("Couldn't read packet: %s", strerror(errno));                          fatal("Couldn't read packet: %s", strerror(errno));
           }
   
         msg_len = buffer_get_int(m);          msg_len = buffer_get_int(m);
         if (msg_len > MAX_MSG_LENGTH)          if (msg_len > MAX_MSG_LENGTH)
                 fatal("Received message too long %u", msg_len);                  fatal("Received message too long %u", msg_len);
   
         buffer_append_space(m, msg_len);          buffer_append_space(m, msg_len);
         len = atomicio(read, fd, buffer_ptr(m), msg_len);          if (atomicio(read, fd, buffer_ptr(m), msg_len) != msg_len) {
         if (len == 0)                  if (errno == EPIPE)
                 fatal("Connection closed");                          fatal("Connection closed");
         else if (len == -1)                  else
                 fatal("Read packet: %s", strerror(errno));                          fatal("Read packet: %s", strerror(errno));
           }
 }  }
   
 static void  static void
Line 172 
Line 173 
                 int status = buffer_get_int(&msg);                  int status = buffer_get_int(&msg);
   
                 error("Couldn't get handle: %s", fx2txt(status));                  error("Couldn't get handle: %s", fx2txt(status));
                   buffer_free(&msg);
                 return(NULL);                  return(NULL);
         } else if (type != SSH2_FXP_HANDLE)          } else if (type != SSH2_FXP_HANDLE)
                 fatal("Expected SSH2_FXP_HANDLE(%u) packet, got %u",                  fatal("Expected SSH2_FXP_HANDLE(%u) packet, got %u",
Line 206 
Line 208 
                         debug("Couldn't stat remote file: %s", fx2txt(status));                          debug("Couldn't stat remote file: %s", fx2txt(status));
                 else                  else
                         error("Couldn't stat remote file: %s", fx2txt(status));                          error("Couldn't stat remote file: %s", fx2txt(status));
                   buffer_free(&msg);
                 return(NULL);                  return(NULL);
         } else if (type != SSH2_FXP_ATTRS) {          } else if (type != SSH2_FXP_ATTRS) {
                 fatal("Expected SSH2_FXP_ATTRS(%u) packet, got %u",                  fatal("Expected SSH2_FXP_ATTRS(%u) packet, got %u",
Line 308 
Line 311 
     SFTP_DIRENT ***dir)      SFTP_DIRENT ***dir)
 {  {
         Buffer msg;          Buffer msg;
         u_int type, id, handle_len, i, expected_id, ents = 0;          u_int count, type, id, handle_len, i, expected_id, ents = 0;
         char *handle;          char *handle;
   
         id = conn->msg_id++;          id = conn->msg_id++;
Line 332 
Line 335 
         }          }
   
         for (; !interrupted;) {          for (; !interrupted;) {
                 int count;  
   
                 id = expected_id = conn->msg_id++;                  id = expected_id = conn->msg_id++;
   
                 debug3("Sending SSH2_FXP_READDIR I:%u", id);                  debug3("Sending SSH2_FXP_READDIR I:%u", id);
Line 741 
Line 742 
         Attrib junk, *a;          Attrib junk, *a;
         Buffer msg;          Buffer msg;
         char *handle;          char *handle;
         int local_fd, status, num_req, max_req, write_error;          int local_fd, status = 0, write_error;
         int read_error, write_errno;          int read_error, write_errno;
         u_int64_t offset, size;          u_int64_t offset, size;
         u_int handle_len, mode, type, id, buflen;          u_int handle_len, mode, type, id, buflen, num_req, max_req;
         off_t progress_counter;          off_t progress_counter;
         struct request {          struct request {
                 u_int id;                  u_int id;
Line 854 
Line 855 
                 debug3("Received reply T:%u I:%u R:%d", type, id, max_req);                  debug3("Received reply T:%u I:%u R:%d", type, id, max_req);
   
                 /* Find the request in our queue */                  /* Find the request in our queue */
                 for(req = TAILQ_FIRST(&requests);                  for (req = TAILQ_FIRST(&requests);
                     req != NULL && req->id != id;                      req != NULL && req->id != id;
                     req = TAILQ_NEXT(req, tq))                      req = TAILQ_NEXT(req, tq))
                         ;                          ;
Line 1103 
Line 1104 
                         debug3("SSH2_FXP_STATUS %d", status);                          debug3("SSH2_FXP_STATUS %d", status);
   
                         /* Find the request in our queue */                          /* Find the request in our queue */
                         for(ack = TAILQ_FIRST(&acks);                          for (ack = TAILQ_FIRST(&acks);
                             ack != NULL && ack->id != r_id;                              ack != NULL && ack->id != r_id;
                             ack = TAILQ_NEXT(ack, tq))                              ack = TAILQ_NEXT(ack, tq))
                                 ;                                  ;
Line 1121 
Line 1122 
                                 goto done;                                  goto done;
                         }                          }
                         debug3("In write loop, ack for %u %u bytes at %llu",                          debug3("In write loop, ack for %u %u bytes at %llu",
                            ack->id, ack->len, (unsigned long long)ack->offset);                              ack->id, ack->len, (unsigned long long)ack->offset);
                         ++ackid;                          ++ackid;
                         xfree(ack);                          xfree(ack);
                 }                  }

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.51.2.3