components/proftpd/patches/011.19693019-proftpd-slow_ls.patch
branchs11u2-sru
changeset 4311 3a33895438c9
parent 4204 04c06044ed82
equal deleted inserted replaced
4294:427b52500a3a 4311:3a33895438c9
       
     1 The fix was developed in-house and submitted upstream. The upstream bug
       
     2 is:
       
     3 
       
     4 http://bugs.proftpd.org/show_bug.cgi?id=4157
       
     5 
       
     6 diff --git a/modules/mod_core.c b/modules/mod_core.c
       
     7 --- a/modules/mod_core.c
       
     8 +++ b/modules/mod_core.c
       
     9 @@ -40,6 +40,7 @@
       
    10  /* From src/main.c */
       
    11  extern unsigned long max_connects;
       
    12  extern unsigned int max_connect_interval;
       
    13 +extern unsigned char tracing_enabled;
       
    14  
       
    15  /* From modules/mod_site.c */
       
    16  extern modret_t *site_dispatch(cmd_rec*);
       
    17 @@ -1381,6 +1382,8 @@
       
    18    int per_session = FALSE;
       
    19    unsigned int idx = 1;
       
    20  
       
    21 +  tracing_enabled = TRUE;
       
    22 +
       
    23    if (cmd->argc-1 < 1)
       
    24      CONF_ERROR(cmd, "wrong number of parameters");
       
    25    CHECK_CONF(cmd, CONF_ROOT);
       
    26 diff --git a/modules/mod_ls.c b/modules/mod_ls.c
       
    27 --- a/modules/mod_ls.c
       
    28 +++ b/modules/mod_ls.c
       
    29 @@ -307,10 +307,12 @@
       
    30  
       
    31  static int sendline(int flags, char *fmt, ...) {
       
    32    va_list msg;
       
    33 -  char buf[PR_TUNABLE_BUFFER_SIZE+1] = {'\0'};
       
    34 +  char buf[PR_TUNABLE_BUFFER_SIZE+1];
       
    35    int res = 0;
       
    36    size_t buflen, listbuflen;
       
    37  
       
    38 +  (void) memset(buf, '\0', sizeof(buf));
       
    39 +
       
    40    if (listbuf == NULL) {
       
    41      listbufsz = pr_config_get_server_xfer_bufsz(PR_NETIO_IO_WR);
       
    42      listbuf = listbuf_ptr = pcalloc(session.pool, listbufsz);
       
    43 diff --git a/src/fsio.c b/src/fsio.c
       
    44 --- a/src/fsio.c
       
    45 +++ b/src/fsio.c
       
    46 @@ -556,10 +556,12 @@
       
    47  static int cache_stat(pr_fs_t *fs, const char *path, struct stat *sbuf,
       
    48      unsigned int op) {
       
    49    int res = -1;
       
    50 -  char pathbuf[PR_TUNABLE_PATH_MAX + 1] = {'\0'};
       
    51 +  char pathbuf[PR_TUNABLE_PATH_MAX + 1];
       
    52    int (*mystat)(pr_fs_t *, const char *, struct stat *) = NULL;
       
    53    size_t pathlen;
       
    54  
       
    55 +  (void) memset(pathbuf, '\0', sizeof(pathbuf));
       
    56 +
       
    57    /* Sanity checks */
       
    58    if (fs == NULL) {
       
    59      errno = EINVAL;
       
    60 @@ -641,8 +643,8 @@
       
    61   * during the hit.
       
    62   */
       
    63  static pr_fs_t *lookup_dir_fs(const char *path, int op) {
       
    64 -  char buf[PR_TUNABLE_PATH_MAX + 1] = {'\0'};
       
    65 -  char tmp_path[PR_TUNABLE_PATH_MAX + 1] = {'\0'};
       
    66 +  char buf[PR_TUNABLE_PATH_MAX + 1];
       
    67 +  char tmp_path[PR_TUNABLE_PATH_MAX + 1];
       
    68    pr_fs_t *fs = NULL;
       
    69    int exact = FALSE;
       
    70    size_t tmp_pathlen = 0;
       
    71 @@ -651,6 +653,9 @@
       
    72    pr_fs_match_t *fsm = NULL;
       
    73  #endif /* PR_FS_MATCH */
       
    74  
       
    75 +  (void) memset(buf, '\0', sizeof(buf));
       
    76 +  (void) memset(tmp_path, '\0', sizeof(tmp_path));
       
    77 +
       
    78    sstrncpy(buf, path, sizeof(buf));
       
    79  
       
    80    /* Check if the given path is an absolute path.  Since there may be
       
    81 diff --git a/src/trace.c b/src/trace.c
       
    82 --- a/src/trace.c
       
    83 +++ b/src/trace.c
       
    84 @@ -32,6 +32,8 @@
       
    85  
       
    86  #ifdef PR_USE_TRACE
       
    87  
       
    88 +unsigned char tracing_enabled = FALSE;
       
    89 +
       
    90  static int trace_logfd = -1;
       
    91  static unsigned long trace_opts = PR_TRACE_OPT_DEFAULT;
       
    92  static pool *trace_pool = NULL;
       
    93 @@ -473,6 +475,10 @@
       
    94    int res;
       
    95    va_list msg;
       
    96  
       
    97 +  /* Optimization: do not run tracing code unless explicitly enabled. */
       
    98 +  if (tracing_enabled == FALSE)
       
    99 +    return 0;
       
   100 +
       
   101    va_start(msg, fmt);
       
   102    res = pr_trace_vmsg(channel, level, fmt, msg);
       
   103    va_end(msg);