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

Diff for /src/usr.bin/ssh/sftp-server.c between version 1.121 and 1.122

version 1.121, 2021/02/12 03:49:09 version 1.122, 2021/02/18 00:30:17
Line 16 
Line 16 
  */   */
   
 #include <sys/types.h>  #include <sys/types.h>
   #include <sys/resource.h>
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/time.h>  #include <sys/time.h>
 #include <sys/mount.h>  #include <sys/mount.h>
Line 45 
Line 46 
   
 char *sftp_realpath(const char *, char *); /* sftp-realpath.c */  char *sftp_realpath(const char *, char *); /* sftp-realpath.c */
   
   /* Maximum data read that we are willing to accept */
   #define SFTP_MAX_READ_LENGTH (64 * 1024)
   
 /* Our verbosity */  /* Our verbosity */
 static LogLevel log_level = SYSLOG_LEVEL_ERROR;  static LogLevel log_level = SYSLOG_LEVEL_ERROR;
   
Line 102 
Line 106 
 static void process_extended_hardlink(u_int32_t id);  static void process_extended_hardlink(u_int32_t id);
 static void process_extended_fsync(u_int32_t id);  static void process_extended_fsync(u_int32_t id);
 static void process_extended_lsetstat(u_int32_t id);  static void process_extended_lsetstat(u_int32_t id);
   static void process_extended_limits(u_int32_t id);
 static void process_extended(u_int32_t id);  static void process_extended(u_int32_t id);
   
 struct sftp_handler {  struct sftp_handler {
Line 144 
Line 149 
         { "hardlink", "hardlink@openssh.com", 0, process_extended_hardlink, 1 },          { "hardlink", "hardlink@openssh.com", 0, process_extended_hardlink, 1 },
         { "fsync", "fsync@openssh.com", 0, process_extended_fsync, 1 },          { "fsync", "fsync@openssh.com", 0, process_extended_fsync, 1 },
         { "lsetstat", "lsetstat@openssh.com", 0, process_extended_lsetstat, 1 },          { "lsetstat", "lsetstat@openssh.com", 0, process_extended_lsetstat, 1 },
           { "limits", "limits@openssh.com", 0, process_extended_limits, 1 },
         { NULL, NULL, 0, NULL, 0 }          { NULL, NULL, 0, NULL, 0 }
 };  };
   
Line 665 
Line 671 
             (r = sshbuf_put_cstring(msg, "1")) != 0 || /* version */              (r = sshbuf_put_cstring(msg, "1")) != 0 || /* version */
             /* lsetstat extension */              /* lsetstat extension */
             (r = sshbuf_put_cstring(msg, "lsetstat@openssh.com")) != 0 ||              (r = sshbuf_put_cstring(msg, "lsetstat@openssh.com")) != 0 ||
               (r = sshbuf_put_cstring(msg, "1")) != 0 || /* version */
               /* limits extension */
               (r = sshbuf_put_cstring(msg, "limits@openssh.com")) != 0 ||
             (r = sshbuf_put_cstring(msg, "1")) != 0) /* version */              (r = sshbuf_put_cstring(msg, "1")) != 0) /* version */
                 fatal_fr(r, "compose");                  fatal_fr(r, "compose");
         send_msg(msg);          send_msg(msg);
Line 731 
Line 740 
 static void  static void
 process_read(u_int32_t id)  process_read(u_int32_t id)
 {  {
         u_char buf[64*1024];          u_char buf[SFTP_MAX_READ_LENGTH];
         u_int32_t len;          u_int32_t len;
         int r, handle, fd, ret, status = SSH2_FX_FAILURE;          int r, handle, fd, ret, status = SSH2_FX_FAILURE;
         u_int64_t off;          u_int64_t off;
Line 1408 
Line 1417 
  out:   out:
         send_status(id, status);          send_status(id, status);
         free(name);          free(name);
   }
   
   static void
   process_extended_limits(u_int32_t id)
   {
           struct sshbuf *msg;
           int r;
           uint64_t nfiles = 0;
           struct rlimit rlim;
   
           debug("request %u: limits", id);
   
           if (getrlimit(RLIMIT_NOFILE, &rlim) != -1 && rlim.rlim_cur > 5)
                   nfiles = rlim.rlim_cur - 5; /* stdio(3) + syslog + spare */
   
           if ((msg = sshbuf_new()) == NULL)
                   fatal_f("sshbuf_new failed");
           if ((r = sshbuf_put_u8(msg, SSH2_FXP_EXTENDED_REPLY)) != 0 ||
               (r = sshbuf_put_u32(msg, id)) != 0 ||
               /* max-packet-length */
               (r = sshbuf_put_u64(msg, SFTP_MAX_MSG_LENGTH)) != 0 ||
               /* max-read-length */
               (r = sshbuf_put_u64(msg, SFTP_MAX_READ_LENGTH)) != 0 ||
               /* max-write-length */
               (r = sshbuf_put_u64(msg, SFTP_MAX_MSG_LENGTH - 1024)) != 0 ||
               /* max-open-handles */
               (r = sshbuf_put_u64(msg, nfiles)) != 0)
                   fatal_fr(r, "compose");
           send_msg(msg);
           sshbuf_free(msg);
 }  }
   
 static void  static void

Legend:
Removed from v.1.121  
changed lines
  Added in v.1.122