"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dynamic-preprocessors/ftptelnet/pp_ftp.c" between
snort-2.9.16.1.tar.gz and snort-2.9.17.tar.gz

About: Snort is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

pp_ftp.c  (snort-2.9.16.1):pp_ftp.c  (snort-2.9.17)
skipping to change at line 69 skipping to change at line 69
#include <windows.h> #include <windows.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include "ftpp_eo_log.h" #include "ftpp_eo_log.h"
#include "pp_ftp.h" #include "pp_ftp.h"
#include "pp_telnet.h" #include "pp_telnet.h"
#include "ftpp_return_codes.h" #include "ftpp_return_codes.h"
#include "ftp_cmd_lookup.h" #include "ftp_cmd_lookup.h"
#include "ftp_bounce_lookup.h" #include "ftp_bounce_lookup.h"
#include "spp_ftptelnet.h"
//#include "decode.h" //#include "decode.h"
#include "snort_debug.h" #include "snort_debug.h"
#include "stream_api.h" #include "stream_api.h"
//#include "plugbase.h" //#include "plugbase.h"
#ifndef MAXHOSTNAMELEN /* Why doesn't Windows define this? */ #ifndef MAXHOSTNAMELEN /* Why doesn't Windows define this? */
#define MAXHOSTNAMELEN 256 #define MAXHOSTNAMELEN 256
#endif #endif
#include "ipv6_port.h" #include "ipv6_port.h"
skipping to change at line 1261 skipping to change at line 1262
} }
else if (Session->data_chan_state & DATA_CHAN_REST_CMD_ISSUED) else if (Session->data_chan_state & DATA_CHAN_REST_CMD_ISSUED)
{ {
if (Session->ftp_cmd_pipe_index == Session->data_xfer_index) if (Session->ftp_cmd_pipe_index == Session->data_xfer_index)
{ {
if (Session->data_chan_index == 0) if (Session->data_chan_index == 0)
Session->ftp_cmd_pipe_index = 1; Session->ftp_cmd_pipe_index = 1;
Session->data_xfer_index = 0; Session->data_xfer_index = 0;
if (rsp_code == 350) if (rsp_code == 350)
{ {
#ifdef TARGET_BASED
FTP_DATA_SESSION *ftpdata = Session->datassn; FTP_DATA_SESSION *ftpdata = Session->datassn;
if(ftpdata) if(ftpdata)
ftpdata->flags |= FTPDATA_FLG_REST; ftpdata->flags |= FTPDATA_FLG_REST;
#endif
} }
else else
Session->rest_cmd_offset= 0; Session->rest_cmd_offset= 0;
Session->data_chan_index = 0; Session->data_chan_index = 0;
Session->data_chan_state &= ~DATA_CHAN_REST_CMD_ISSUED; Session->data_chan_state &= ~DATA_CHAN_REST_CMD_ISSUED;
} }
} }
else if (Session->data_chan_state & DATA_CHAN_XFER_CMD_ISSUED) else if (Session->data_chan_state & DATA_CHAN_XFER_CMD_ISSUED)
{ {
if (Session->ftp_cmd_pipe_index == Session->data_xfer_index) if (Session->ftp_cmd_pipe_index == Session->data_xfer_index)
skipping to change at line 1363 skipping to change at line 1366
int check_ftp(FTP_SESSION *ftpssn, SFSnortPacket *p, int iMode) int check_ftp(FTP_SESSION *ftpssn, SFSnortPacket *p, int iMode)
{ {
int iRet = FTPP_SUCCESS; int iRet = FTPP_SUCCESS;
int encrypted = 0; int encrypted = 0;
int space = 0; int space = 0;
long state = FTP_CMD_OK; long state = FTP_CMD_OK;
int rsp_code = 0; int rsp_code = 0;
FTPTELNET_GLOBAL_CONF *global_conf = (FTPTELNET_GLOBAL_CONF *)sfPolicyUserDa taGet(ftpssn->global_conf, ftpssn->policy_id); FTPTELNET_GLOBAL_CONF *global_conf = (FTPTELNET_GLOBAL_CONF *)sfPolicyUserDa taGet(ftpssn->global_conf, ftpssn->policy_id);
FTP_CLIENT_REQ *req; FTP_CLIENT_REQ *req;
FTP_CMD_CONF *CmdConf = NULL; FTP_CMD_CONF *CmdConf = NULL;
#ifdef TARGET_BASED
FTP_DATA_SESSION *datassn; FTP_DATA_SESSION *datassn;
#endif
const unsigned char *read_ptr; const unsigned char *read_ptr;
const unsigned char *end = p->payload + p->payload_size; const unsigned char *end = p->payload + p->payload_size;
if (_dpd.Is_DetectFlag(SF_FLAG_ALT_DECODE)) if (_dpd.Is_DetectFlag(SF_FLAG_ALT_DECODE))
end = _dpd.altBuffer->data + _dpd.altBuffer->len; end = _dpd.altBuffer->data + _dpd.altBuffer->len;
if (iMode == FTPP_SI_CLIENT_MODE) if (iMode == FTPP_SI_CLIENT_MODE)
{ {
req = &ftpssn->client.request; req = &ftpssn->client.request;
skipping to change at line 1868 skipping to change at line 1873
ftpssn->file_xfer_info = FTPP_FILE_IGNORE; ftpssn->file_xfer_info = FTPP_FILE_IGNORE;
} }
// Get the file name and set direction of the get/put re quest. // Get the file name and set direction of the get/put re quest.
// Request could have been sent without parameters, i.e. filename, // Request could have been sent without parameters, i.e. filename,
// so make sure something is there. // so make sure something is there.
if (((req->param_begin != NULL) && (req->param_size > 0) ) if (((req->param_begin != NULL) && (req->param_size > 0) )
&& (CmdConf->file_get_cmd || CmdConf->file_put_c md)) && (CmdConf->file_get_cmd || CmdConf->file_put_c md))
{ {
ftpssn->filename = (char *)malloc(req->param_size+1) ; ftpssn->filename = (char *)malloc(req->param_size+1) ;
ftp_telnet_stats.heap_memory += req->param_size+1;
if (ftpssn->filename) if (ftpssn->filename)
{ {
memcpy(ftpssn->filename, req->param_begin, req-> param_size); memcpy(ftpssn->filename, req->param_begin, req-> param_size);
ftpssn->filename[req->param_size] = '\0'; ftpssn->filename[req->param_size] = '\0';
ftpssn->file_xfer_info = req->param_size; ftpssn->file_xfer_info = req->param_size;
if (ftpssn->flags & FTP_FLG_MALWARE_ENABLED) if (ftpssn->flags & FTP_FLG_MALWARE_ENABLED)
{ {
IP_COPY_VALUE(ftpssn->control_clientIP, GET_ SRC_IP(p)); IP_COPY_VALUE(ftpssn->control_clientIP, GET_ SRC_IP(p));
IP_COPY_VALUE(ftpssn->control_serverIP, GET_ DST_IP(p)); IP_COPY_VALUE(ftpssn->control_serverIP, GET_ DST_IP(p));
ftpssn->control_serverPort = ntohs(p->tcp_he ader->destination_port); ftpssn->control_serverPort = ntohs(p->tcp_he ader->destination_port);
ftpssn->control_clientPort = ntohs(p->tcp_he ader->source_port); ftpssn->control_clientPort = ntohs(p->tcp_he ader->source_port);
#ifdef TARGET_BASED
datassn = (FTP_DATA_SESSION *)ftpssn->datass n; datassn = (FTP_DATA_SESSION *)ftpssn->datass n;
if(datassn) if(datassn)
{ {
char *file_name = strrchr(ftpssn->filena me, '/'); char *file_name = strrchr(ftpssn->filena me, '/');
if(!file_name) if(!file_name)
file_name = ftpssn->filename; file_name = ftpssn->filename;
datassn->path_hash = _dpd.fileAPI->str_t o_hash((uint8_t *)file_name, strlen(file_name)); datassn->path_hash = _dpd.fileAPI->str_t o_hash((uint8_t *)file_name, strlen(file_name));
} }
#endif
} }
} }
else else
{ {
_dpd.errMsg("check_ftp: " _dpd.errMsg("check_ftp: "
"Memory allocation failed for filename i n ftpssn\n"); "Memory allocation failed for filename i n ftpssn\n");
} }
// 0 for Download, 1 for Upload // 0 for Download, 1 for Upload
ftpssn->data_xfer_dir = CmdConf->file_get_cmd ? fals e : true; ftpssn->data_xfer_dir = CmdConf->file_get_cmd ? fals e : true;
FTP_DATA_SESSION *ftpdata = ftpssn->datassn; FTP_DATA_SESSION *ftpdata = ftpssn->datassn;
 End of changes. 8 change blocks. 
0 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)