summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2006-10-13 19:13:18 (UTC)
committer Michael Krelin <hacker@klever.net>2006-10-13 19:13:18 (UTC)
commit325e7fc43721df3efaa8539190fada6e6e3aa8fa (patch) (side-by-side diff)
treeec03bf74e17eb497e0fcd31b521192b0b14bd83e
parent577427e68ef10a4d2b75d28e42b22952ae3bcf23 (diff)
downloadpumpkin-325e7fc43721df3efaa8539190fada6e6e3aa8fa.zip
pumpkin-325e7fc43721df3efaa8539190fada6e6e3aa8fa.tar.gz
pumpkin-325e7fc43721df3efaa8539190fada6e6e3aa8fa.tar.bz2
Enabled logging of outgoing errors, added reject with explicit error message
when file is too large for the block size set. git-svn-id: http://svn.klever.net/kin/pumpkin/trunk@192 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--PumpKINDlg.cpp7
-rw-r--r--pumpkin.rc5
-rw-r--r--resource.h2
3 files changed, 10 insertions, 4 deletions
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp
index 2a01918..bb15211 100644
--- a/PumpKINDlg.cpp
+++ b/PumpKINDlg.cpp
@@ -757,48 +757,53 @@ CFileException e;
OnHostKnown();
}else{
tftp::tftpOptions o;
CString v;
if(m_Options.Lookup(tftpoBSize,v)){
m__blkSize=atoi(v);
if(m__blkSize){
m_blkSize=m__blkSize;
v.Format("%u",m_blkSize);
o[tftpoBSize]=v;
}
}
if(m_Options.Lookup(tftpoTSize,v)){
v.Format("%lu",m_xferSize);
o[tftpoTSize]=v;
}
if(m_Options.Lookup(tftpoTOut,v)){
m__timeOut=atoi(v);
if(m__timeOut){
m_timeOut=m__timeOut;
v.Format("%u",m_timeOut);
o[tftpoTOut]=v;
}
}
+ // XXX: see if we can enforce our preference regarding block size here.
+ if(m_xferSize >= (m_blkSize<<16)) {
+ Deny(tftp::errUndefined,IDS_TFTP_ERROR_TOOBIG);
+ return TRUE;
+ }
state = stateXfer;
m_ACK=0;
if(o.GetCount()){
tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o));
ASSERT(p);
p->SetOpcode(tftp::opOACK);
p->data.m_OACK.Set(&o);
PostTFTP(p,TRUE);
}else
DoXfer();
}
return TRUE;
}
CRRQSocket::CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin)
: CXferSocket(daddy,fileName,type,sin)
{
m_ACK=0;
m_LastSlack=0;
}
UINT tftp::tftpERROR::tftpSize(LPCTSTR msg)
{
return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpERROR::tftpErrorCode)+strlen(msg)+1;
@@ -857,53 +862,51 @@ tftp *p = tftp::Allocate(tftp::tftpDATA::tftpSize(m_blkSize));
state=stateClosing; m_ACKtoClose = m_ACK+1;
}
}CATCH(CFileException,e){
Deny(e);
}END_CATCH
}
UINT tftp::tftpDATA::tftpSize(UINT blkSize)
{
return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpDATA)
-sizeof(BYTE)+blkSize;
}
void CXferSocket::Deny(CFileException* e)
{
PostError(e);
state=stateDeny;
}
void CXferSocket::PostError(UINT errCode,UINT errID)
{
CString msg;
msg.LoadString(errID);
ASSERT(m_Daddy);
-/* // ***
CString tmp;
tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg);
m_Daddy->LogLine(tmp);
- */
tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg));
err->SetOpcode(tftp::opERROR);
err->errSet(errCode,msg);
PostTFTP(err);
}
void CXferSocket::PostError(CFileException* e)
{
UINT eCode;
UINT eMsgID;
switch(e->m_cause){
case CFileException::fileNotFound:
eCode=tftp::errNotFound;
eMsgID=IDS_TFTP_ERROR_NOTFOUND;
break;
case CFileException::accessDenied:
eCode=tftp::errAccessViolation;
eMsgID=IDS_TFTP_ERROR_ACCESS;
break;
case CFileException::directoryFull:
eCode=tftp::errDiskFull;
eMsgID=IDS_TFTP_ERROR_DIRFULL;
break;
case CFileException::sharingViolation:
diff --git a/pumpkin.rc b/pumpkin.rc
index 5ce2438..adca112 100644
--- a/pumpkin.rc
+++ b/pumpkin.rc
@@ -76,49 +76,49 @@ IDI_REMOVE ICON DISCARDABLE "res\\remove.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 74
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About PumpKIN"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,7,17,18,20
LTEXT "PumpKIN, Version 2.7.1",IDC_STATIC,40,15,119,8,
SS_NOPREFIX
LTEXT "Copyright © 1997-2006 Klever Group",IDC_STATIC,40,30,
170,8
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
PUSHBUTTON "http://www.klever.net/",IDC_KLEVERNET,124,53,86,14
END
IDD_PUMPKIN_DIALOG DIALOGEX 0, 0, 362, 193
STYLE DS_3DLOOK | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW
CAPTION " PumpKIN"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
CONTROL "List1",IDC_CONNECTIONS,"SysListView32",LVS_REPORT |
LVS_AUTOARRANGE | WS_BORDER | WS_TABSTOP,7,7,295,108,
WS_EX_DLGMODALFRAME
PUSHBUTTON "&Get File",IDC_GET,305,7,50,17,BS_NOTIFY,
WS_EX_CLIENTEDGE
PUSHBUTTON "&Put File",IDC_PUT,305,25,50,17,BS_NOTIFY,
WS_EX_CLIENTEDGE
PUSHBUTTON "&Abort xfer",IDC_ABORT,305,43,50,17,BS_NOTIFY,
WS_EX_CLIENTEDGE
PUSHBUTTON "&Options",IDC_OPTIONS,305,61,50,17,BS_NOTIFY,
WS_EX_CLIENTEDGE
PUSHBUTTON "E&xit",IDC_EXIT,305,79,50,17,BS_NOTIFY,WS_EX_CLIENTEDGE
PUSHBUTTON "&Help",ID_HELP,305,97,50,17,BS_NOTIFY,WS_EX_CLIENTEDGE
LISTBOX IDC_LOG,7,115,348,64,LBS_USETABSTOPS |
LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL |
WS_HSCROLL,WS_EX_DLGMODALFRAME
PUSHBUTTON "..",IDCANCEL,0,183,6,7,NOT WS_VISIBLE | NOT WS_TABSTOP
CONTROL "&Server is running",IDC_LISTENING,"Button",
BS_AUTOCHECKBOX | BS_LEFTTEXT | BS_FLAT | WS_TABSTOP,286,
181,69,11,WS_EX_TRANSPARENT | WS_EX_STATICEDGE
END
IDD_PROPS_SERVER DIALOG DISCARDABLE 0, 0, 300, 201
@@ -541,49 +541,49 @@ STRINGTABLE DISCARDABLE
BEGIN
IDS_ABOUTBOX "&About PumpKIN..."
IDS_FMT_BYTES "%lu"
IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
IDS_TFTP_ERROR_ACCESS "Access violation"
IDS_TFTP_ERROR_NOTFOUND "File not found"
IDS_TFTP_ERROR_DIRFULL "Directory is full"
IDS_TFTP_ERROR_SHARING "Sharing violation"
IDS_TFTP_ERROR_DISKFULL "Disk full"
IDS_TFTP_ERROR_UNDEFINED "Undefined error"
IDS_LOG_START "PumpKIN started"
IDS_LOG_LISTENRECEIVEERROR "Error listening for incoming connections"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_LOG_LISTENACCEPTERROR "Error accepting incoming connection"
IDS_LOG_RRQSERVE "'%s' of type '%s' is requested from %s"
IDS_LOG_LISTENOPCODE "Invalid opcode in initial connection request"
IDS_LOG_XFERUDPSEND "UDP packet send failed"
IDS_LOG_XFERRECEIVE "Error on xfer socket"
IDS_LOG_XFERSEND "Error on xfer socket"
IDS_LOG_XFERUDPRECEIVE "UDP packet receive failed"
IDS_LOG_XFERSOURCETID "Packet from unexpected source"
- IDS_LOG_SENTTFTPERROR ":%u: %s"
+ IDS_LOG_SENTTFTPERROR ">> %u: %s"
IDS_LOG_GOTTFTPERROR "TFTP:%u: %s"
IDS_LOG_XFEROPCODE "Invalid opcode (%u) during transfer received"
IDS_LOG_XFERRRQFINISHED "Transfer of '%s' has successfully completed"
IDS_TITLE_OPTIONS "Options"
IDS_LOG_WRQSERVE "Writing of '%s' of type '%s' is requested by %s"
IDS_TFTP_ERROR_FAILEDTORENAME "Too many clones of the file"
IDS_RENAME_TITLE "Save As"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_LOG_TIMEDOUT "Transmission of '%s' is timed out"
IDS_CONFIRMEXIT_TITLE "Exit"
IDS_CONFIRMEXIT_TEXT "File transmission is currently in progress. Are you sure you want to exit?"
IDS_LOG_XFERWRQFINISHED "Transfer of '%s' has successfully completed"
IDS_LOG_XFERABORTED "Transfer of '%s' was aborted"
IDS_TITLE_PUTREQUEST "Send file"
IDS_TITLE_GETREQUEST "Fetch file"
IDS_WTALKHEADING "Talk with "
IDS_TITLE_BROWSEFILE "Browse"
IDS_LOG_RESOLVEFAILED "Failed to resolve host address for '%s'"
IDS_LOG_FAILEDLOCALFILE "Failed to open local file '%s'"
IDS_LOG_FAILEDTOOPEN "Failed to open '%s'"
IDS_OTALXHEADING "Open Talks: talking to "
@@ -635,48 +635,49 @@ BEGIN
IDS_LOG_SENDING "Sending '%s' to '%s'"
IDS_WTALKAT "@"
IDS_OTALXAT " at "
IDS_TFTP_ERROR_TSIZE "Invalid transfer size"
IDS_TFTP_ERROR_BSIZE "Invalid block size"
IDS_TFTP_ERROR_TOUT "Invalid timeout"
IDS_SELECT_TFTPROOT "Select TFTP filesystem root.."
IDS_FILTER_WAV "Sound Files (*.wav)|*.wav||"
IDS_TITLE_WAV "Select sound.."
IDS_BOX_CANTBIND "Failed to create listening socket. The port may be in use by another application."
IDS_NO_XFER_OP "No request type specified."
IDS_INVALID_IP "Invalid IP address."
IDS_INVALID_NETMASK "Invalid netmask."
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "PUMPKIN"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_INVALID_RULE "Invalid access rule."
IDS_LOG_LOGERROR "Error logging to '%s'"
+ IDS_TFTP_ERROR_TOOBIG "File is too big, try increasing block size"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "res\PumpKIN.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
diff --git a/resource.h b/resource.h
index 1bdce59..7961e5e 100644
--- a/resource.h
+++ b/resource.h
@@ -67,48 +67,50 @@
#define IDS_DROPFILES_TITLE 144
#define IDS_NOMULTIPLEDROP_TEXT 145
#define IDI_BROWSE 145
#define IDS_LOG_REQUESTING 146
#define IDS_LOG_SENDING 147
#define IDS_WTALKAT 148
#define IDS_OTALXAT 149
#define IDI_PLAY 149
#define IDS_TFTP_ERROR_TSIZE 150
#define IDD_PROPS_ACL 150
#define IDS_TFTP_ERROR_BSIZE 151
#define IDS_TFTP_ERROR_TOUT 152
#define IDI_UP 152
#define IDS_SELECT_TFTPROOT 153
#define IDI_DOWN 153
#define IDS_FILTER_WAV 154
#define IDI_REMOVE 154
#define IDS_TITLE_WAV 155
#define IDS_BOX_CANTBIND 156
#define IDS_NO_XFER_OP 157
#define IDS_INVALID_IP 158
#define IDS_INVALID_NETMASK 159
#define IDS_INVALID_RULE 160
#define IDS_LOG_LOGERROR 161
+#define IDS_TFTP_ERROR_TOOBIG 162
+#define IDS_LOG_DENYING 163
#define IDC_KLEVERNET 1000
#define IDC_CONNECTIONS 1001
#define IDC_LOG 1003
#define IDC_GET 1004
#define IDC_PUT 1005
#define IDC_ABORT 1006
#define IDC_EXIT 1007
#define IDC_TFTPROOT 1008
#define IDC_TFTPSUBDIRS 1009
#define IDC_RRQ_GIVEALL 1010
#define IDC_RRQ_ALWAYSCONFIRM 1011
#define IDC_RRQ_DENYALL 1012
#define IDC_WRQ_TAKEALL 1013
#define IDC_WRQ_PROMPTEXISTING 1014
#define IDC_WRQ_ALWAYSCONFIRM 1015
#define IDC_WRQ_DENYALL 1016
#define IDC_PROMPTTIMEOUT 1017
#define IDC_LISTENPORT 1018
#define IDC_LISTENSPIN 1019
#define IDC_SPEAKPORT 1020
#define IDC_SPEAKSPIN 1021
#define IDC_MAXUDPSIZE 1022
#define IDC_MAXUDPSPIN 1023
#define IDC_TIMEOUT 1024