summaryrefslogtreecommitdiffabout
path: root/PumpKINDlg.cpp
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 /PumpKINDlg.cpp
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 (limited to 'PumpKINDlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--PumpKINDlg.cpp7
1 files changed, 5 insertions, 2 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: