cpt

changeset 20:f7f4ece55b36

fix memory violation on request without \r
author marco (@macarony.de - Matthias Diener)
date Tue, 19 Aug 2008 16:25:47 +0200
parents 568b58e30d48
children 2d7a6cc332bb
files cpt.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/cpt.c	Thu Mar 20 19:43:34 2008 +0100
     1.2 +++ b/cpt.c	Tue Aug 19 16:25:47 2008 +0200
     1.3 @@ -32,7 +32,9 @@
     1.4  #define sizeof_array(array) (sizeof(array) / sizeof(array[0]))
     1.5  
     1.6  /* if DAEMON_DIR doesn't exist, it will be created */
     1.7 -#define DAEMON_DIR "/var/run/cpt"
     1.8 +#ifndef DAEMON_DIR
     1.9 +# define DAEMON_DIR "/var/run/cpt"
    1.10 +#endif /* DAEMON_DIR */
    1.11  #ifndef PID_FILE
    1.12  # define PID_FILE DAEMON_DIR"/cpt.pid"
    1.13  #endif /* PID_FILE */
    1.14 @@ -507,7 +509,7 @@
    1.15      }
    1.16    }
    1.17    /* trim \r */
    1.18 -  if(request_line[(i - 1)] == '\r') {
    1.19 +  if((i > 0) && (request_line[(i - 1)] == '\r')) {
    1.20      i--;
    1.21    }
    1.22    request_line[i] = 0;
    1.23 @@ -595,6 +597,9 @@
    1.24        dest_port = atoi(&host_port[(j + 1)]);
    1.25        host_port[j] = 0;
    1.26      }
    1.27 +#if ((defined(USE_SYSLOG) || defined(USE_LOGFILE)) && (((USE_SYSLOG | USE_LOGFILE) & CPT_DEBUG) == CPT_DEBUG))
    1.28 +              write_log(CPT_DEBUG, "split dest - host: %s, Port: %d\n", host_port, dest_port);
    1.29 +#endif /* ((defined(USE_SYSLOG) || defined(USE_LOGFILE)) && (((USE_SYSLOG | USE_LOGFILE) & CPT_DEBUG) == CPT_DEBUG)) */
    1.30      return dest_port;
    1.31  }
    1.32