author | Michael Krelin <hacker@klever.net> | 2006-10-13 19:13:18 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-10-13 19:13:18 (UTC) |
commit | 325e7fc43721df3efaa8539190fada6e6e3aa8fa (patch) (unidiff) | |
tree | ec03bf74e17eb497e0fcd31b521192b0b14bd83e | |
parent | 577427e68ef10a4d2b75d28e42b22952ae3bcf23 (diff) | |
download | pumpkin-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
-rw-r--r-- | PumpKINDlg.cpp | 7 | ||||
-rw-r--r-- | pumpkin.rc | 5 | ||||
-rw-r--r-- | resource.h | 2 |
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 | |||
@@ -769,24 +769,29 @@ CFileException e; | |||
769 | if(m_Options.Lookup(tftpoTSize,v)){ | 769 | if(m_Options.Lookup(tftpoTSize,v)){ |
770 | v.Format("%lu",m_xferSize); | 770 | v.Format("%lu",m_xferSize); |
771 | o[tftpoTSize]=v; | 771 | o[tftpoTSize]=v; |
772 | } | 772 | } |
773 | if(m_Options.Lookup(tftpoTOut,v)){ | 773 | if(m_Options.Lookup(tftpoTOut,v)){ |
774 | m__timeOut=atoi(v); | 774 | m__timeOut=atoi(v); |
775 | if(m__timeOut){ | 775 | if(m__timeOut){ |
776 | m_timeOut=m__timeOut; | 776 | m_timeOut=m__timeOut; |
777 | v.Format("%u",m_timeOut); | 777 | v.Format("%u",m_timeOut); |
778 | o[tftpoTOut]=v; | 778 | o[tftpoTOut]=v; |
779 | } | 779 | } |
780 | } | 780 | } |
781 | // XXX: see if we can enforce our preference regarding block size here. | ||
782 | if(m_xferSize >= (m_blkSize<<16)) { | ||
783 | Deny(tftp::errUndefined,IDS_TFTP_ERROR_TOOBIG); | ||
784 | return TRUE; | ||
785 | } | ||
781 | state = stateXfer; | 786 | state = stateXfer; |
782 | m_ACK=0; | 787 | m_ACK=0; |
783 | if(o.GetCount()){ | 788 | if(o.GetCount()){ |
784 | tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o)); | 789 | tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o)); |
785 | ASSERT(p); | 790 | ASSERT(p); |
786 | p->SetOpcode(tftp::opOACK); | 791 | p->SetOpcode(tftp::opOACK); |
787 | p->data.m_OACK.Set(&o); | 792 | p->data.m_OACK.Set(&o); |
788 | PostTFTP(p,TRUE); | 793 | PostTFTP(p,TRUE); |
789 | }else | 794 | }else |
790 | DoXfer(); | 795 | DoXfer(); |
791 | } | 796 | } |
792 | return TRUE; | 797 | return TRUE; |
@@ -869,29 +874,27 @@ UINT tftp::tftpDATA::tftpSize(UINT blkSize) | |||
869 | 874 | ||
870 | void CXferSocket::Deny(CFileException* e) | 875 | void CXferSocket::Deny(CFileException* e) |
871 | { | 876 | { |
872 | PostError(e); | 877 | PostError(e); |
873 | state=stateDeny; | 878 | state=stateDeny; |
874 | } | 879 | } |
875 | 880 | ||
876 | void CXferSocket::PostError(UINT errCode,UINT errID) | 881 | void CXferSocket::PostError(UINT errCode,UINT errID) |
877 | { | 882 | { |
878 | CString msg; | 883 | CString msg; |
879 | msg.LoadString(errID); | 884 | msg.LoadString(errID); |
880 | ASSERT(m_Daddy); | 885 | ASSERT(m_Daddy); |
881 | /*// *** | ||
882 | CString tmp; | 886 | CString tmp; |
883 | tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg); | 887 | tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg); |
884 | m_Daddy->LogLine(tmp); | 888 | m_Daddy->LogLine(tmp); |
885 | */ | ||
886 | tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg)); | 889 | tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg)); |
887 | err->SetOpcode(tftp::opERROR); | 890 | err->SetOpcode(tftp::opERROR); |
888 | err->errSet(errCode,msg); | 891 | err->errSet(errCode,msg); |
889 | PostTFTP(err); | 892 | PostTFTP(err); |
890 | } | 893 | } |
891 | 894 | ||
892 | void CXferSocket::PostError(CFileException* e) | 895 | void CXferSocket::PostError(CFileException* e) |
893 | { | 896 | { |
894 | UINT eCode; | 897 | UINT eCode; |
895 | UINT eMsgID; | 898 | UINT eMsgID; |
896 | switch(e->m_cause){ | 899 | switch(e->m_cause){ |
897 | case CFileException::fileNotFound: | 900 | case CFileException::fileNotFound: |
@@ -88,25 +88,25 @@ BEGIN | |||
88 | LTEXT "PumpKIN, Version 2.7.1",IDC_STATIC,40,15,119,8, | 88 | LTEXT "PumpKIN, Version 2.7.1",IDC_STATIC,40,15,119,8, |
89 | SS_NOPREFIX | 89 | SS_NOPREFIX |
90 | LTEXT "Copyright © 1997-2006 Klever Group",IDC_STATIC,40,30, | 90 | LTEXT "Copyright © 1997-2006 Klever Group",IDC_STATIC,40,30, |
91 | 170,8 | 91 | 170,8 |
92 | DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP | 92 | DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP |
93 | PUSHBUTTON "http://www.klever.net/",IDC_KLEVERNET,124,53,86,14 | 93 | PUSHBUTTON "http://www.klever.net/",IDC_KLEVERNET,124,53,86,14 |
94 | END | 94 | END |
95 | 95 | ||
96 | IDD_PUMPKIN_DIALOG DIALOGEX 0, 0, 362, 193 | 96 | IDD_PUMPKIN_DIALOG DIALOGEX 0, 0, 362, 193 |
97 | STYLE DS_3DLOOK | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | 97 | STYLE DS_3DLOOK | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
98 | EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW | 98 | EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW |
99 | CAPTION " PumpKIN" | 99 | CAPTION " PumpKIN" |
100 | FONT 8, "MS Sans Serif" | 100 | FONT 8, "MS Sans Serif", 0, 0, 0x1 |
101 | BEGIN | 101 | BEGIN |
102 | CONTROL "List1",IDC_CONNECTIONS,"SysListView32",LVS_REPORT | | 102 | CONTROL "List1",IDC_CONNECTIONS,"SysListView32",LVS_REPORT | |
103 | LVS_AUTOARRANGE | WS_BORDER | WS_TABSTOP,7,7,295,108, | 103 | LVS_AUTOARRANGE | WS_BORDER | WS_TABSTOP,7,7,295,108, |
104 | WS_EX_DLGMODALFRAME | 104 | WS_EX_DLGMODALFRAME |
105 | PUSHBUTTON "&Get File",IDC_GET,305,7,50,17,BS_NOTIFY, | 105 | PUSHBUTTON "&Get File",IDC_GET,305,7,50,17,BS_NOTIFY, |
106 | WS_EX_CLIENTEDGE | 106 | WS_EX_CLIENTEDGE |
107 | PUSHBUTTON "&Put File",IDC_PUT,305,25,50,17,BS_NOTIFY, | 107 | PUSHBUTTON "&Put File",IDC_PUT,305,25,50,17,BS_NOTIFY, |
108 | WS_EX_CLIENTEDGE | 108 | WS_EX_CLIENTEDGE |
109 | PUSHBUTTON "&Abort xfer",IDC_ABORT,305,43,50,17,BS_NOTIFY, | 109 | PUSHBUTTON "&Abort xfer",IDC_ABORT,305,43,50,17,BS_NOTIFY, |
110 | WS_EX_CLIENTEDGE | 110 | WS_EX_CLIENTEDGE |
111 | PUSHBUTTON "&Options",IDC_OPTIONS,305,61,50,17,BS_NOTIFY, | 111 | PUSHBUTTON "&Options",IDC_OPTIONS,305,61,50,17,BS_NOTIFY, |
112 | WS_EX_CLIENTEDGE | 112 | WS_EX_CLIENTEDGE |
@@ -553,25 +553,25 @@ BEGIN | |||
553 | END | 553 | END |
554 | 554 | ||
555 | STRINGTABLE DISCARDABLE | 555 | STRINGTABLE DISCARDABLE |
556 | BEGIN | 556 | BEGIN |
557 | IDS_LOG_LISTENACCEPTERROR "Error accepting incoming connection" | 557 | IDS_LOG_LISTENACCEPTERROR "Error accepting incoming connection" |
558 | IDS_LOG_RRQSERVE "'%s' of type '%s' is requested from %s" | 558 | IDS_LOG_RRQSERVE "'%s' of type '%s' is requested from %s" |
559 | IDS_LOG_LISTENOPCODE "Invalid opcode in initial connection request" | 559 | IDS_LOG_LISTENOPCODE "Invalid opcode in initial connection request" |
560 | IDS_LOG_XFERUDPSEND "UDP packet send failed" | 560 | IDS_LOG_XFERUDPSEND "UDP packet send failed" |
561 | IDS_LOG_XFERRECEIVE "Error on xfer socket" | 561 | IDS_LOG_XFERRECEIVE "Error on xfer socket" |
562 | IDS_LOG_XFERSEND "Error on xfer socket" | 562 | IDS_LOG_XFERSEND "Error on xfer socket" |
563 | IDS_LOG_XFERUDPRECEIVE "UDP packet receive failed" | 563 | IDS_LOG_XFERUDPRECEIVE "UDP packet receive failed" |
564 | IDS_LOG_XFERSOURCETID "Packet from unexpected source" | 564 | IDS_LOG_XFERSOURCETID "Packet from unexpected source" |
565 | IDS_LOG_SENTTFTPERROR ":%u: %s" | 565 | IDS_LOG_SENTTFTPERROR ">> %u: %s" |
566 | IDS_LOG_GOTTFTPERROR "TFTP:%u: %s" | 566 | IDS_LOG_GOTTFTPERROR "TFTP:%u: %s" |
567 | IDS_LOG_XFEROPCODE "Invalid opcode (%u) during transfer received" | 567 | IDS_LOG_XFEROPCODE "Invalid opcode (%u) during transfer received" |
568 | IDS_LOG_XFERRRQFINISHED "Transfer of '%s' has successfully completed" | 568 | IDS_LOG_XFERRRQFINISHED "Transfer of '%s' has successfully completed" |
569 | IDS_TITLE_OPTIONS "Options" | 569 | IDS_TITLE_OPTIONS "Options" |
570 | IDS_LOG_WRQSERVE "Writing of '%s' of type '%s' is requested by %s" | 570 | IDS_LOG_WRQSERVE "Writing of '%s' of type '%s' is requested by %s" |
571 | IDS_TFTP_ERROR_FAILEDTORENAME "Too many clones of the file" | 571 | IDS_TFTP_ERROR_FAILEDTORENAME "Too many clones of the file" |
572 | IDS_RENAME_TITLE "Save As" | 572 | IDS_RENAME_TITLE "Save As" |
573 | END | 573 | END |
574 | 574 | ||
575 | STRINGTABLE DISCARDABLE | 575 | STRINGTABLE DISCARDABLE |
576 | BEGIN | 576 | BEGIN |
577 | IDS_LOG_TIMEDOUT "Transmission of '%s' is timed out" | 577 | IDS_LOG_TIMEDOUT "Transmission of '%s' is timed out" |
@@ -647,24 +647,25 @@ BEGIN | |||
647 | IDS_INVALID_NETMASK "Invalid netmask." | 647 | IDS_INVALID_NETMASK "Invalid netmask." |
648 | END | 648 | END |
649 | 649 | ||
650 | STRINGTABLE DISCARDABLE | 650 | STRINGTABLE DISCARDABLE |
651 | BEGIN | 651 | BEGIN |
652 | AFX_IDS_APP_TITLE "PUMPKIN" | 652 | AFX_IDS_APP_TITLE "PUMPKIN" |
653 | END | 653 | END |
654 | 654 | ||
655 | STRINGTABLE DISCARDABLE | 655 | STRINGTABLE DISCARDABLE |
656 | BEGIN | 656 | BEGIN |
657 | IDS_INVALID_RULE "Invalid access rule." | 657 | IDS_INVALID_RULE "Invalid access rule." |
658 | IDS_LOG_LOGERROR "Error logging to '%s'" | 658 | IDS_LOG_LOGERROR "Error logging to '%s'" |
659 | IDS_TFTP_ERROR_TOOBIG "File is too big, try increasing block size" | ||
659 | END | 660 | END |
660 | 661 | ||
661 | #endif // English (U.S.) resources | 662 | #endif // English (U.S.) resources |
662 | ///////////////////////////////////////////////////////////////////////////// | 663 | ///////////////////////////////////////////////////////////////////////////// |
663 | 664 | ||
664 | 665 | ||
665 | 666 | ||
666 | #ifndef APSTUDIO_INVOKED | 667 | #ifndef APSTUDIO_INVOKED |
667 | ///////////////////////////////////////////////////////////////////////////// | 668 | ///////////////////////////////////////////////////////////////////////////// |
668 | // | 669 | // |
669 | // Generated from the TEXTINCLUDE 3 resource. | 670 | // Generated from the TEXTINCLUDE 3 resource. |
670 | // | 671 | // |
@@ -79,24 +79,26 @@ | |||
79 | #define IDI_UP 152 | 79 | #define IDI_UP 152 |
80 | #define IDS_SELECT_TFTPROOT 153 | 80 | #define IDS_SELECT_TFTPROOT 153 |
81 | #define IDI_DOWN 153 | 81 | #define IDI_DOWN 153 |
82 | #define IDS_FILTER_WAV 154 | 82 | #define IDS_FILTER_WAV 154 |
83 | #define IDI_REMOVE 154 | 83 | #define IDI_REMOVE 154 |
84 | #define IDS_TITLE_WAV 155 | 84 | #define IDS_TITLE_WAV 155 |
85 | #define IDS_BOX_CANTBIND 156 | 85 | #define IDS_BOX_CANTBIND 156 |
86 | #define IDS_NO_XFER_OP 157 | 86 | #define IDS_NO_XFER_OP 157 |
87 | #define IDS_INVALID_IP 158 | 87 | #define IDS_INVALID_IP 158 |
88 | #define IDS_INVALID_NETMASK 159 | 88 | #define IDS_INVALID_NETMASK 159 |
89 | #define IDS_INVALID_RULE 160 | 89 | #define IDS_INVALID_RULE 160 |
90 | #define IDS_LOG_LOGERROR 161 | 90 | #define IDS_LOG_LOGERROR 161 |
91 | #define IDS_TFTP_ERROR_TOOBIG 162 | ||
92 | #define IDS_LOG_DENYING 163 | ||
91 | #define IDC_KLEVERNET 1000 | 93 | #define IDC_KLEVERNET 1000 |
92 | #define IDC_CONNECTIONS 1001 | 94 | #define IDC_CONNECTIONS 1001 |
93 | #define IDC_LOG 1003 | 95 | #define IDC_LOG 1003 |
94 | #define IDC_GET 1004 | 96 | #define IDC_GET 1004 |
95 | #define IDC_PUT 1005 | 97 | #define IDC_PUT 1005 |
96 | #define IDC_ABORT 1006 | 98 | #define IDC_ABORT 1006 |
97 | #define IDC_EXIT 1007 | 99 | #define IDC_EXIT 1007 |
98 | #define IDC_TFTPROOT 1008 | 100 | #define IDC_TFTPROOT 1008 |
99 | #define IDC_TFTPSUBDIRS 1009 | 101 | #define IDC_TFTPSUBDIRS 1009 |
100 | #define IDC_RRQ_GIVEALL 1010 | 102 | #define IDC_RRQ_GIVEALL 1010 |
101 | #define IDC_RRQ_ALWAYSCONFIRM 1011 | 103 | #define IDC_RRQ_ALWAYSCONFIRM 1011 |
102 | #define IDC_RRQ_DENYALL 1012 | 104 | #define IDC_RRQ_DENYALL 1012 |